<commit_before>package com.dstevens.users;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class PatronageRepository {

	private PatronageDao dao;

	@Autowired
	public PatronageRepository(PatronageDao dao) {
		this.dao = dao;
	}

	public Iterable<Patronage> findAllUndeleted() {
		return dao.findAll();
	}

	public Patronage findPatronage(Integer id) {
		return dao.findOne(id);
	}
	
	public Patronage findPatronageByMembershipId(String membershipId) {
		return dao.findOne(Integer.valueOf(membershipId.substring(4)));
	}
	
	public Patronage save(Patronage patronage) {
		return dao.save(patronage);
	}
	
	
	
}<commit_msg>Fixed potential bug when trying to look up patronage with a null or too-short membership id<commit_after>package com.dstevens.users;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class PatronageRepository {

	private PatronageDao dao;

	@Autowired
	public PatronageRepository(PatronageDao dao) {
		this.dao = dao;
	}

	public Iterable<Patronage> findAllUndeleted() {
		return dao.findAll();
	}

	public Patronage findPatronage(Integer id) {
		if(id != null) {
			return dao.findOne(id);
		}
		return null;
	}
	
	public Patronage findPatronageByMembershipId(String membershipId) {
		if(membershipId != null && membershipId.length() > 4) {
			return dao.findOne(Integer.valueOf(membershipId.substring(4)));
		}
		return null;
	}
	
	public Patronage save(Patronage patronage) {
		return dao.save(patronage);
	}
	
	
	
}
{'fraction_non_alphanumeric': 0.09745499689633767, 'fraction_numerical': 0.00186219739292365, 'mean_word_length': 5.014925373134329, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3866448', 'n_tokens_mistral': 574, 'n_tokens_neox': 545, 'n_words': 109}