<commit_before>package org.dannil.httpdownloader.service;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidKeySpecException;

import org.dannil.httpdownloader.model.User;
import org.dannil.httpdownloader.repository.UserRepository;
import org.dannil.httpdownloader.utility.PasswordUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Class which handles back end operations for registering.
 * 
 * @author <NAME>
 */
@Service(value = "RegisterService")
public final class RegisterService implements IRegisterService {

	@Autowired
	private UserRepository userRepository;

	/**
	 * Persist the specified user.
	 * 
	 * @see org.springframework.data.repository.CrudRepository#save(Object)
	 */
	@Override
	public final User save(final User user) {
		try {
			user.setPassword(PasswordUtility.getHashedPassword(user.getPassword()));
		} catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchProviderException e) {
			throw new RuntimeException(e);
		}
		return this.userRepository.save(user);
	}

	/**
	 * Find a user by it's email.
	 * 
	 * @see org.dannil.httpdownloader.repository.UserRepository#findByEmail(String)
	 */
	@Override
	public final User findByEmail(final String email) {
		return this.userRepository.findByEmail(email);
	}

}
<commit_msg>Added deep copying due to error discovered during tests<commit_after>package org.dannil.httpdownloader.service;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidKeySpecException;

import org.dannil.httpdownloader.model.User;
import org.dannil.httpdownloader.repository.UserRepository;
import org.dannil.httpdownloader.utility.PasswordUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Class which handles back end operations for registering.
 * 
 * @author <NAME>
 */
@Service(value = "RegisterService")
public final class RegisterService implements IRegisterService {

	@Autowired
	private UserRepository userRepository;

	/**
	 * Persist the specified user.
	 * 
	 * @see org.springframework.data.repository.CrudRepository#save(Object)
	 */
	@Override
	public final User save(final User user) {
		final User temp = new User(user);
		try {
			temp.setPassword(PasswordUtility.getHashedPassword(temp.getPassword()));
		} catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchProviderException e) {
			throw new RuntimeException(e);
		}
		return this.userRepository.save(temp);
	}

	/**
	 * Find a user by it's email.
	 * 
	 * @see org.dannil.httpdownloader.repository.UserRepository#findByEmail(String)
	 */
	@Override
	public final User findByEmail(final String email) {
		return this.userRepository.findByEmail(email);
	}

}

{'fraction_non_alphanumeric': 0.09604328711531958, 'fraction_numerical': 0.0, 'mean_word_length': 4.845849802371541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4045332', 'n_tokens_mistral': 879, 'n_tokens_neox': 839, 'n_words': 177}