Source:
<code>protected synchronized void createUser(final String user, final String group) throws GenieException { final CommandLine idCheckCommandLine = new CommandLine("id"); idCheckCommandLine.addArgument("-u"); idCheckCommandLine.addArgument(user); try { this.executor.execute(idCheckCommandLine); log.debug("User already exists"); } catch (final IOException ioe) { log.debug("User does not exist. Creating it now."); <START> if (group != null && !group.equals(user) && StringUtils.isNotBlank(group)) { <END> log.debug("Group and User are different so creating group now."); final CommandLine groupCreateCommandLine = new CommandLine("sudo"); groupCreateCommandLine.addArgument("groupadd"); groupCreateCommandLine.addArgument(group); try { log.debug("Running command [" + groupCreateCommandLine.toString() + "]"); this.executor.execute(groupCreateCommandLine); } catch (IOException ioexception) { log.debug("Group creation threw an error as it might already exist"); } } final CommandLine userCreateCommandLine = new CommandLine("sudo"); userCreateCommandLine.addArgument("useradd"); userCreateCommandLine.addArgument(user); if (StringUtils.isNotBlank(group) && !group.equals(user)) { userCreateCommandLine.addArgument("-G"); userCreateCommandLine.addArgument(group); } userCreateCommandLine.addArgument("-M"); try { log.debug("Running command [" + userCreateCommandLine.toString() + "]"); this.executor.execute(userCreateCommandLine); } catch (IOException ioexception) { throw new GenieServerException("Could not create user " + user + " with exception " + ioexception); } } }</code><technical_language>check for null call StringUtils.isNotBlank redundant. IsNotBlank checks for null I put first</technical_language>

Target:
protected synchronized void createUser(final String user, final String group) throws GenieException { final CommandLine idCheckCommandLine = new CommandLine("id"); idCheckCommandLine.addArgument("-u"); idCheckCommandLine.addArgument(user); try { this.executor.execute(idCheckCommandLine); log.debug("User already exists"); } catch (final IOException ioe) { log.debug("User does not exist. Creating it now."); final boolean isGroupValid = StringUtils.isNotBlank(group) && !group.equals(user); if (isGroupValid) { log.debug("Group and User are different so creating group now."); final CommandLine groupCreateCommandLine = new CommandLine("sudo"); groupCreateCommandLine.addArgument("groupadd"); groupCreateCommandLine.addArgument(group); try { log.debug("Running command to create group: [" + groupCreateCommandLine.toString() + "]"); this.executor.execute(groupCreateCommandLine); } catch (IOException ioexception) { log.debug("Group creation threw an error as it might already exist"); } } final CommandLine userCreateCommandLine = new CommandLine("sudo"); userCreateCommandLine.addArgument("useradd"); userCreateCommandLine.addArgument(user); if (isGroupValid) { userCreateCommandLine.addArgument("-G"); userCreateCommandLine.addArgument(group); } userCreateCommandLine.addArgument("-M"); try { log.debug("Running command to create user: [" + userCreateCommandLine.toString() + "]"); this.executor.execute(userCreateCommandLine); } catch (IOException ioexception) { throw new GenieServerException("Could not create user " + user + " with exception " + ioexception); } } }