auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void unbind(final String eventName, final SubscriptionEventListener listener) { validateArguments(eventName, listener); final Set<SubscriptionEventListener> listeners = eventNameToListenerMap.get(eventName); synchronized (lock) { if (listeners != null) { listeners.remove(listener); if (listeners.isEmpty()) { eventNameToListenerMap.remove(eventName); } } } }

Target:
public void unbind(final String eventName, final SubscriptionEventListener listener) { validateArguments(eventName, listener); synchronized (lock) { final Set<SubscriptionEventListener> listeners = eventNameToListenerMap.get(eventName); if (listeners != null) { listeners.remove(listener); if (listeners.isEmpty()) { eventNameToListenerMap.remove(eventName); } } } }
Source:
public String downloadIgnite(String ver) throws IOException { assert ver != null; URL url; if (ver.equals(ClusterProperties.DEFAULT_IGNITE_VERSION)) { ver = findLatestVersion(); url = new URL(String.format(findMirror() + IGNITE_PATH, ver, ver)); } else { url = new URL(String.format(DOWNLOAD_URL_PATTERN, ver, ver)); } return downloadIgnite(url); }

Target:
public String downloadIgnite(String ver) throws IOException { assert ver != null; URL url; if (ver.equals(ClusterProperties.DEFAULT_IGNITE_VERSION)) { try { ver = findLatestVersion(); url = new URL(String.format(findMirror() + IGNITE_PATH, ver, ver)); } catch (Exception e) { url = new URL(String.format(DOWNLOAD_URL_PATTERN, ver, ver)); } } else { url = new URL(String.format(DOWNLOAD_URL_PATTERN, ver, ver)); } return downloadIgnite(url); }
Source:
private static Map<String, TemplateResolverFactory<LogEvent, EventResolverContext, ? extends TemplateResolver<LogEvent>>> createResolverFactoryByName() { final List<EventResolverFactory<? extends EventResolver>> resolverFactories = Arrays.asList( ContextDataResolverFactory.getInstance(), ContextStackResolverFactory.getInstance(), EndOfBatchResolverFactory.getInstance(), ExceptionResolverFactory.getInstance(), ExceptionRootCauseResolverFactory.getInstance(), LevelResolverFactory.getInstance(), LoggerResolverFactory.getInstance(), MainMapResolverFactory.getInstance(), MapResolverFactory.getInstance(), MarkerResolverFactory.getInstance(), MessageResolverFactory.getInstance(), SourceResolverFactory.getInstance(), ThreadResolverFactory.getInstance(), TimestampResolverFactory.getInstance()); final Map<String, TemplateResolverFactory<LogEvent, EventResolverContext, ? extends TemplateResolver<LogEvent>>> resolverFactoryByName = new LinkedHashMap<>(); for (final EventResolverFactory<? extends EventResolver> resolverFactory : resolverFactories) { resolverFactoryByName.put(resolverFactory.getName(), resolverFactory); } return Collections.unmodifiableMap(resolverFactoryByName); }

Target:
private static Map<String, TemplateResolverFactory<LogEvent, EventResolverContext, ? extends TemplateResolver<LogEvent>>> createResolverFactoryByName() { final List<EventResolverFactory<? extends EventResolver>> resolverFactories = Arrays.asList( ContextDataResolverFactory.getInstance(), ContextStackResolverFactory.getInstance(), EndOfBatchResolverFactory.getInstance(), ExceptionResolverFactory.getInstance(), ExceptionRootCauseResolverFactory.getInstance(), LevelResolverFactory.getInstance(), LoggerResolverFactory.getInstance(), MainMapResolverFactory.getInstance(), MapResolverFactory.getInstance(), MarkerResolverFactory.getInstance(), MessageResolverFactory.getInstance(), PatternResolverFactory.getInstance(), SourceResolverFactory.getInstance(), ThreadResolverFactory.getInstance(), TimestampResolverFactory.getInstance()); final Map<String, TemplateResolverFactory<LogEvent, EventResolverContext, ? extends TemplateResolver<LogEvent>>> resolverFactoryByName = new LinkedHashMap<>(); for (final EventResolverFactory<? extends EventResolver> resolverFactory : resolverFactories) { resolverFactoryByName.put(resolverFactory.getName(), resolverFactory); } return Collections.unmodifiableMap(resolverFactoryByName); }
Source:
public void saveApplicationShouldSaveAProperApplicationDTOAndStateDTO() { final StateDTO stateDTO = StateDTO.builder().channel(new ChannelDTO(8L,null)).candidateId(1L).position(new PositionDTO(1L,null)).description("sss").stateType("newstate").stateIndex(0).build(); given(modelMapper.map(applicationDTO, ApplicationEntity.class)).willReturn(applicationEntity); given(candidateRepository.findOne(CANDIDATE_ID)).willReturn(candidateEntity); given(positionRepository.findOne(POSITION_ID)).willReturn(positionEntity); given(channelRepository.findOne(CHANNEL_ID)).willReturn(channelEntity); given(applicationsRepository.save(applicationEntity)).willReturn(this.applicationEntity); Long result = applicationsService.saveApplicaton(applicationDTO,stateDTO); assertNotNull(result); assertEquals(APPLICATION_ID, result); then(statesService).should().saveState(stateDTO,APPLICATION_ID); }

Target:
public void saveApplicationShouldSaveAProperApplicationDTOAndStateDTO() { final StateDTO stateDTO = StateDTO.builder().channel(new ChannelDTO(8L,null)).candidateId(1L).position(new PositionDTO(1L,null)).description("sss").stateType("newstate").stateIndex(0).build(); given(modelMapper.map(applicationDTO, ApplicationEntity.class)).willReturn(applicationEntity); given(candidateRepository.findOne(CANDIDATE_ID)).willReturn(candidateEntity); given(positionRepository.findOne(POSITION_ID)).willReturn(positionEntity); given(channelRepository.findOne(CHANNEL_ID)).willReturn(channelEntity); given(applicationsRepository.save(applicationEntity)).willReturn(this.applicationEntity); Long result = applicationsService.saveApplicaton(applicationDTO,stateDTO); assertNotNull(result); assertEquals(APPLICATION_ID, result); then(statesService).should().saveState(stateDTO,APPLICATION_ID); then(modelMapper).should().map(applicationDTO, ApplicationEntity.class); then(candidateRepository).should().findOne(CANDIDATE_ID); then(positionRepository).should().findOne(POSITION_ID); then(channelRepository).should().findOne(CHANNEL_ID); then(applicationsRepository).should().save(applicationEntity); }
Source:
private void syncAccounts() { OpacClient app = (OpacClient) getApplication(); AccountDataSource data = new AccountDataSource(this); data.open(); List<Account> accounts = data.getAccountsWithPassword(); for (Account account : accounts) { if (BuildConfig.DEBUG) Log.i(NAME, "Loading data for Account " + account.toString()); try { Library library = app.getLibrary(account.getLibrary()); if (!library.isAccountSupported()) continue; OpacApi api = app.getNewApi(library); AccountData res = api.account(account); if (res == null) continue; data.storeCachedAccountData(account, res); data.close(); new ReminderHelper(app).generateAlarms(); } catch (JSONException | IOException | OpacApi.OpacErrorException e) { data.close(); e.printStackTrace(); } } }

Target:
private void syncAccounts() { OpacClient app = (OpacClient) getApplication(); AccountDataSource data = new AccountDataSource(this); data.open(); List<Account> accounts = data.getAccountsWithPassword(); data.close(); for (Account account : accounts) { if (BuildConfig.DEBUG) Log.i(NAME, "Loading data for Account " + account.toString()); try { Library library = app.getLibrary(account.getLibrary()); if (!library.isAccountSupported()) continue; OpacApi api = app.getNewApi(library); AccountData res = api.account(account); if (res == null) continue; data.open(); data.storeCachedAccountData(account, res); data.close(); new ReminderHelper(app).generateAlarms(); } catch (JSONException | IOException | OpacApi.OpacErrorException e) { data.close(); e.printStackTrace(); failed = true; } } }
Source:
public void filter(final MethodNode methodNode, final IFilterContext context, final IFilterOutput output) { if ((methodNode.access & Opcodes.ACC_SYNTHETIC) == 0) { return; } if (methodNode.name.startsWith("lambda$")) { return; } if (KotlinGeneratedFilter.isKotlinClass(context)) { if (KotlinDefaultArgumentsFilter .isDefaultArgumentsMethodName(methodNode.name)) { return; } final Type methodType = Type.getMethodType(methodNode.desc); final int lastArgument = methodType.getArgumentTypes().length - 1; if (lastArgument >= 0 && "kotlin.coroutines.Continuation" .equals(methodType.getArgumentTypes()[lastArgument] .getClassName())) { return; } } output.ignore(methodNode.instructions.getFirst(), methodNode.instructions.getLast()); }

Target:
public void filter(final MethodNode methodNode, final IFilterContext context, final IFilterOutput output) { if ((methodNode.access & Opcodes.ACC_SYNTHETIC) == 0) { return; } if (methodNode.name.startsWith("lambda$")) { return; } if (KotlinGeneratedFilter.isKotlinClass(context)) { if (KotlinDefaultArgumentsFilter .isDefaultArgumentsMethodName(methodNode.name)) { return; } if (KotlinCoroutineFilter.isLastArgumentContinuation(methodNode)) { return; } } output.ignore(methodNode.instructions.getFirst(), methodNode.instructions.getLast()); }
Source:
public void setDenyRootedJailBroken(Boolean newValue) throws Throwable { if (sourceImmutablePolicy == null) { throw new Throwable("Source Policy is null cannot set deny rooted jailbroken"); } if (sourceImmutablePolicy instanceof MethodAmountPolicy) { sourceImmutablePolicy = new MethodAmountPolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), ((MethodAmountPolicy) sourceImmutablePolicy).getAmount()); } else if (sourceImmutablePolicy instanceof FactorsPolicy) { FactorsPolicy factorsPolicy = (FactorsPolicy) sourceImmutablePolicy; sourceImmutablePolicy = new FactorsPolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), factorsPolicy.isInherenceRequired(), factorsPolicy.isKnowledgeRequired(), factorsPolicy.isPossessionRequired()); } else if (sourceImmutablePolicy instanceof ConditionalGeoFencePolicy) { sourceImmutablePolicy = new ConditionalGeoFencePolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), ((ConditionalGeoFencePolicy) sourceImmutablePolicy).getInPolicy(), ((ConditionalGeoFencePolicy) sourceImmutablePolicy).getOutPolicy()); } else { throw new Throwable("Source Policy is of unknown type"); } }

Target:
public void setDenyRootedJailBroken(Boolean newValue) throws Throwable { if (sourceImmutablePolicy == null) { throw new Throwable("Source Policy is null and therefore unable to deny rooted jailbroken devices."); } if (sourceImmutablePolicy instanceof MethodAmountPolicy) { sourceImmutablePolicy = new MethodAmountPolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), ((MethodAmountPolicy) sourceImmutablePolicy).getAmount()); } else if (sourceImmutablePolicy instanceof FactorsPolicy) { FactorsPolicy factorsPolicy = (FactorsPolicy) sourceImmutablePolicy; sourceImmutablePolicy = new FactorsPolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), factorsPolicy.isInherenceRequired(), factorsPolicy.isKnowledgeRequired(), factorsPolicy.isPossessionRequired()); } else if (sourceImmutablePolicy instanceof ConditionalGeoFencePolicy) { sourceImmutablePolicy = new ConditionalGeoFencePolicy(newValue, sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), ((ConditionalGeoFencePolicy) sourceImmutablePolicy).getInside(), ((ConditionalGeoFencePolicy) sourceImmutablePolicy).getOutside()); } else { throw new Throwable("Source Policy is of unknown type"); } }
Source:
public String evaluate(TransactionContext txnCtx, Input<Object>[] args) { assert args.length == 2 : "repeat takes exactly two arguments"; var text = (String) args[0].value(); if (text == null) { return null; } var repetitions = (int) args[1].value(); if (repetitions <= 0) { return ""; } else { return text.repeat(repetitions); } }

Target:
public String evaluate(TransactionContext txnCtx, Input<Object>[] args) { assert args.length == 2 : "repeat takes exactly two arguments"; var text = (String) args[0].value(); var repetitions = (Integer) args[1].value(); if (text == null || repetitions == null) { return null; } if (repetitions <= 0) { return ""; } else { return text.repeat(repetitions); } }
Source:
private void processOutput() { CallContext callContext = getCallContext(); if(callContext != null) { while (processOutput((CallContextImpl) callContext)); } }

Target:
private void processOutput() { CallContextImpl callContext = getCallContext(); if(callContext != null) { while (processOutput(callContext)); } }
Source:
public void setDeclarator(IASTDeclarator declarator) { assertNotFrozen(); fDeclarator = declarator; fDeclarator.setParent(this); }

Target:
public void setDeclarator(IASTDeclarator declarator) { assertNotFrozen(); fDeclarator = declarator; if (declarator != null) { declarator.setParent(this); declarator.setPropertyInParent(DECLARATOR); } }
Source:
void incrementCommittedTransactions(long duration) { TxCommitStatistic prev, next; if (duration == 0) duration = 1; do { prev = commitStatistic.get(); long prevCount = prev.getNumberOfCommittedTransactions(); long newCount = prevCount + 1; long newAvg = (duration + prevCount * prev.getAverageCommitTime()); newAvg = (newAvg + newCount - 1) / newCount; next = new TxCommitStatistic(newCount, newAvg); } while (!commitStatistic.compareAndSet(prev, next)); }

Target:
void incrementCommittedTransactions(long duration) { TxCommitStatistic prev, next; do { prev = commitStatistic.get(); long prevCount = prev.getNumberOfCommittedTransactions(); long nextAvg = nextAverage(duration, prevCount, prev.getAverageCommitTime()); next = new TxCommitStatistic(prevCount + 1, nextAvg); } while (!commitStatistic.compareAndSet(prev, next)); }
Source:
private void checkStatement(Tree parentStart, Tree parentEnd, StatementTree firstInnerStatement, int nestingStatementNum, List<StatementTree> statements) { if (firstInnerStatement.is(Kind.BLOCK)) { return; } int parentLine = ((PHPTree) parentEnd).getLastToken().line(); int parentColumn = ((PHPTree) parentStart).getFirstToken().column(); StatementBlock statementBlock = findBlock(parentLine, parentColumn, firstInnerStatement, nestingStatementNum, statements); if (!statementBlock.otherStatement.isEmpty()) { boolean isIfStatement = statements.get(nestingStatementNum).is(Kind.IF_STATEMENT); String message = String.format(isIfStatement ? MESSAGE_IF : MESSAGE_LOOP, statementBlock.size()); PreciseIssue issue = context().newIssue(this, statementBlock.otherStatement.get(0), message); issue.secondary(firstInnerStatement, isIfStatement ? "Executed conditionally" : "Executed in a loop"); String secondaryMessage = isIfStatement ? "Always executed" : "Executed once"; statementBlock.otherStatement.stream().skip(1).forEach(statement -> issue.secondary(statement, secondaryMessage)); } }

Target:
private void checkStatement(Tree parentStart, Tree parentEnd, StatementTree firstInnerStatement, int nestingStatementNum, List<StatementTree> statements) { if (firstInnerStatement.is(Kind.BLOCK)) { return; } int parentLine = lastTokenLine(parentEnd); int parentColumn = column(parentStart); StatementBlock statementBlock = findBlock(parentLine, parentColumn, firstInnerStatement, nestingStatementNum, statements); if (!statementBlock.otherStatement.isEmpty()) { boolean isIfStatement = statements.get(nestingStatementNum).is(Kind.IF_STATEMENT); String message = String.format(isIfStatement ? MESSAGE_IF : MESSAGE_LOOP, statementBlock.size()); PreciseIssue issue = context().newIssue(this, statementBlock.otherStatement.get(0), message); issue.secondary(firstInnerStatement, isIfStatement ? "Executed conditionally" : "Executed in a loop"); String secondaryMessage = isIfStatement ? "Always executed" : "Executed once"; statementBlock.otherStatement.stream().skip(1).forEach(statement -> issue.secondary(statement, secondaryMessage)); } }
Source:
public int compare(CompressedWishlistInfo wish1, CompressedWishlistInfo wish2) { int retVal = 0; for (SortOption option : options) { try { switch (option.getKey()) { case CardDbAdapter.KEY_NAME: { retVal = wish1.mCard.mName.compareTo(wish2.mCard.mName); break; } case CardDbAdapter.KEY_COLOR: { retVal = wish1.mCard.mColor.compareTo(wish2.mCard.mColor); break; } case CardDbAdapter.KEY_SUPERTYPE: { retVal = wish1.mCard.mType.compareTo(wish2.mCard.mType); break; } case CardDbAdapter.KEY_CMC: { retVal = wish1.mCard.mCmc - wish2.mCard.mCmc; break; } case CardDbAdapter.KEY_POWER: { retVal = Float.compare(wish1.mCard.mPower, wish2.mCard.mPower); break; } case CardDbAdapter.KEY_TOUGHNESS: { retVal = Float.compare(wish1.mCard.mToughness, wish2.mCard.mToughness); break; } case CardDbAdapter.KEY_SET: { retVal = wish1.mCard.mExpansion.compareTo(wish2.mCard.mExpansion); break; } case SortOrderDialogFragment.KEY_PRICE: { retVal = Double.compare(wish1.getTotalPrice(mPriceSetting), wish2.getTotalPrice(mPriceSetting)); break; } case SortOrderDialogFragment.KEY_ORDER: { retVal = SortOrderDialogFragment.compareInt(wish1.getIndex(), wish2.getIndex()); break; } } } catch (NullPointerException e) { retVal = 0; } if (!option.getAscending()) { retVal = -retVal; } if (retVal != 0) { return retVal; } } return retVal; }

Target:
public int compare(CompressedWishlistInfo wish1, CompressedWishlistInfo wish2) { int retVal = 0; for (SortOption option : options) { try { switch (option.getKey()) { case CardDbAdapter.KEY_NAME: { retVal = wish1.mCard.mName.compareTo(wish2.mCard.mName); break; } case CardDbAdapter.KEY_COLOR: { retVal = wish1.mCard.mColor.compareTo(wish2.mCard.mColor); break; } case CardDbAdapter.KEY_SUPERTYPE: { retVal = wish1.mCard.mType.compareTo(wish2.mCard.mType); break; } case CardDbAdapter.KEY_CMC: { retVal = wish1.mCard.mCmc - wish2.mCard.mCmc; break; } case CardDbAdapter.KEY_POWER: { retVal = Float.compare(wish1.mCard.mPower, wish2.mCard.mPower); break; } case CardDbAdapter.KEY_TOUGHNESS: { retVal = Float.compare(wish1.mCard.mToughness, wish2.mCard.mToughness); break; } case CardDbAdapter.KEY_SET: { retVal = wish1.mCard.mExpansion.compareTo(wish2.mCard.mExpansion); break; } case SortOrderDialogFragment.KEY_PRICE: { retVal = Double.compare(wish1.getTotalPrice(mPriceSetting), wish2.getTotalPrice(mPriceSetting)); break; } case SortOrderDialogFragment.KEY_ORDER: { retVal = Integer.valueOf(wish1.getIndex()).compareTo(wish2.getIndex()); break; } } } catch (NullPointerException e) { retVal = 0; } if (!option.getAscending()) { retVal = -retVal; } if (retVal != 0) { return retVal; } } return retVal; }
Source:
public void setUp() throws Exception { }

Target:
public void setUp() throws Exception { super.setUp(); TasksUiPlugin.getDefault() .getPreferenceStore() .setValue(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false); TaskTestUtil.resetTaskListAndRepositories(); mockRepositoryConnector = new MockRepositoryConnectorWithTaskDataHandler(); TasksUiPlugin.getRepositoryManager().addRepositoryConnector(mockRepositoryConnector); mockRepository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, MockRepositoryConnector.REPOSITORY_URL); TasksUiPlugin.getRepositoryManager().addRepository(mockRepository); }
Source:
public String locate(String name, StatementContext ctx) { final String cache_key; if (ctx.getSqlObjectType() != null) { cache_key = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql"; } else { cache_key = name; } if (found.containsKey(cache_key)) { return found.get(cache_key); } if (looksLikeSql(name)) { return name; } final ClassLoader loader = selectClassLoader(); BufferedReader reader = null; try { InputStream in_stream = loader.getResourceAsStream(name); if (in_stream == null) { in_stream = loader.getResourceAsStream(name + ".sql"); } if (in_stream == null && ctx.getSqlObjectType() != null) { String filename = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql"; in_stream = loader.getResourceAsStream(filename); if (in_stream == null) { in_stream = ctx.getSqlObjectType().getResourceAsStream(filename); } } if (in_stream == null) { found.put(cache_key, name == cache_key ? new String(name) : name); return name; } StringBuilder sb = new StringBuilder(); try { SqlScriptLexer lexer = new SqlScriptLexer(new ANTLRInputStream(in_stream)); while (true) { Token t = lexer.nextToken(); int type = t.getType(); if (type == SqlScriptLexer.EOF) { break; } else if (type == SqlScriptLexer.LITERAL || type == SqlScriptLexer.QUOTED_TEXT || type == SqlScriptLexer.SEMICOLON || type == SqlScriptLexer.OTHER) { sb.append(t.getText()); } else if (type == SqlScriptLexer.NEWLINE) { if (sb.length() > 0) { sb.append(t.getText()); } } } }catch (IOException e){ throw new UnableToCreateStatementException(e.getMessage(), e, ctx); } String sql = sb.toString(); found.put(cache_key, sql); return sql; } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { } } }

Target:
public String locate(String name, StatementContext ctx) { final String cache_key; if (ctx.getSqlObjectType() != null) { cache_key = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql"; } else { cache_key = name; } if (found.containsKey(cache_key)) { return found.get(cache_key); } if (looksLikeSql(name)) { return name; } final ClassLoader loader = selectClassLoader(); InputStream in_stream = null; try { in_stream = loader.getResourceAsStream(name); if (in_stream == null) { in_stream = loader.getResourceAsStream(name + ".sql"); } if (in_stream == null && ctx.getSqlObjectType() != null) { String filename = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql"; in_stream = loader.getResourceAsStream(filename); if (in_stream == null) { in_stream = ctx.getSqlObjectType().getResourceAsStream(filename); } } if (in_stream == null) { found.put(cache_key, name == cache_key ? new String(name) : name); return name; } String sql; try { sql = SQL_SCRIPT_PARSER.parse(new ANTLRInputStream(in_stream)); } catch (IOException e) { throw new UnableToCreateStatementException(e.getMessage(), e, ctx); } found.put(cache_key, sql); return sql; } finally { try { if (in_stream != null) { in_stream.close(); } } catch (IOException e) { } } }
Source:
MockVoltPort(VoltNetwork vn, InputHandler handler) throws UnknownHostException { super (vn, handler, new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 21212), vn.m_pool, null); }

Target:
MockVoltPort(VoltNetwork vn, InputHandler handler) throws UnknownHostException { super (vn, handler, new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 21212), vn.m_pool); }
Source:
public Response buildLinkedAccountURI(@PathParam("providerId") String providerId, @QueryParam("redirectUri") String redirectUri) { if (redirectUri == null) { ErrorResponse.error(Messages.INVALID_REDIRECT_URI, Response.Status.BAD_REQUEST); } String errorMessage = checkCommonPreconditions(providerId); if (errorMessage != null) { return ErrorResponse.error(errorMessage, Response.Status.BAD_REQUEST); } try { String nonce = UUID.randomUUID().toString(); MessageDigest md = MessageDigest.getInstance("SHA-256"); String input = nonce + auth.getSession().getId() + client.getClientId() + providerId; byte[] check = md.digest(input.getBytes(StandardCharsets.UTF_8)); String hash = Base64Url.encode(check); URI linkUri = Urls.identityProviderLinkRequest(this.session.getContext().getUri().getBaseUri(), providerId, realm.getName()); linkUri = UriBuilder.fromUri(linkUri) .queryParam("nonce", nonce) .queryParam("hash", hash) .queryParam("client_id", client.getClientId()) .queryParam("redirect_uri", redirectUri) .build(); AccountLinkUriRepresentation rep = new AccountLinkUriRepresentation(); rep.setAccountLinkUri(linkUri); rep.setHash(hash); rep.setNonce(nonce); return Cors.add(request, Response.ok(rep)).auth().allowedOrigins(auth.getToken()).build(); } catch (Exception spe) { spe.printStackTrace(); return ErrorResponse.error(Messages.FAILED_TO_PROCESS_RESPONSE, Response.Status.INTERNAL_SERVER_ERROR); } }

Target:
public Response buildLinkedAccountURI(@PathParam("providerId") String providerId, @QueryParam("redirectUri") String redirectUri) { auth.require(AccountRoles.MANAGE_ACCOUNT); if (redirectUri == null) { ErrorResponse.error(Messages.INVALID_REDIRECT_URI, Response.Status.BAD_REQUEST); } String errorMessage = checkCommonPreconditions(providerId); if (errorMessage != null) { return ErrorResponse.error(errorMessage, Response.Status.BAD_REQUEST); } try { String nonce = UUID.randomUUID().toString(); MessageDigest md = MessageDigest.getInstance("SHA-256"); String input = nonce + auth.getSession().getId() + client.getClientId() + providerId; byte[] check = md.digest(input.getBytes(StandardCharsets.UTF_8)); String hash = Base64Url.encode(check); URI linkUri = Urls.identityProviderLinkRequest(this.session.getContext().getUri().getBaseUri(), providerId, realm.getName()); linkUri = UriBuilder.fromUri(linkUri) .queryParam("nonce", nonce) .queryParam("hash", hash) .queryParam("client_id", client.getClientId()) .queryParam("redirect_uri", redirectUri) .build(); AccountLinkUriRepresentation rep = new AccountLinkUriRepresentation(); rep.setAccountLinkUri(linkUri); rep.setHash(hash); rep.setNonce(nonce); return Cors.add(request, Response.ok(rep)).auth().allowedOrigins(auth.getToken()).build(); } catch (Exception spe) { spe.printStackTrace(); return ErrorResponse.error(Messages.FAILED_TO_PROCESS_RESPONSE, Response.Status.INTERNAL_SERVER_ERROR); } }
Source:
public static void registerEcore(String ecorePath) throws IOException { if (ecorePath == null) { return; } Integer previousValue = ECOREPATH_TO_REGISTEREDCOUNT.get(ecorePath); if (previousValue == null || previousValue < 0) { previousValue = 0; } ECOREPATH_TO_REGISTEREDCOUNT.put(ecorePath, ++previousValue); determineWorkspaceDepedencies(ecorePath); final ResourceSet physicalResourceSet = new ResourceSetImpl(); initResourceSet(physicalResourceSet, true); final URI uri = URI.createPlatformResourceURI(ecorePath, false); final Resource r = physicalResourceSet.createResource(uri); r.load(null); int rsSize = physicalResourceSet.getResources().size(); EcoreUtil.resolveAll(physicalResourceSet); while (rsSize != physicalResourceSet.getResources().size()) { EcoreUtil.resolveAll(physicalResourceSet); rsSize = physicalResourceSet.getResources().size(); } final ResourceSetImpl virtualResourceSet = new ResourceSetImpl(); for (final Resource physicalResource : physicalResourceSet.getResources()) { if (physicalResource.getContents().size() == 0) { continue; } final EObject eObject = physicalResource.getContents().get(0); final EPackage ePackage = EPackage.class.cast(eObject); if (isContainedInPackageRegistry(ePackage.getNsURI())) { final EPackage registeredPackage = EPackage.Registry.INSTANCE.getEPackage(ePackage.getNsURI()); if (!ePackage.equals(registeredPackage)) { EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage); updateRegistryAndLocalCache(ePackage, physicalResource, virtualResourceSet); } continue; } updateRegistryAndLocalCache(ePackage, physicalResource, virtualResourceSet); } }

Target:
public static void registerEcore(String ecorePath) throws IOException { if (ecorePath == null) { return; } Integer previousValue = ECOREPATH_TO_REGISTEREDCOUNT.get(ecorePath); if (previousValue == null || previousValue < 0) { previousValue = 0; } ECOREPATH_TO_REGISTEREDCOUNT.put(ecorePath, ++previousValue); determineWorkspaceDepedencies(ecorePath); final ResourceSet physicalResourceSet = new ResourceSetImpl(); initResourceSet(physicalResourceSet, true); final URI uri = URI.createPlatformResourceURI(ecorePath, false); final Resource r = physicalResourceSet.createResource(uri); r.load(null); int rsSize = physicalResourceSet.getResources().size(); EcoreUtil.resolveAll(physicalResourceSet); while (rsSize != physicalResourceSet.getResources().size()) { EcoreUtil.resolveAll(physicalResourceSet); rsSize = physicalResourceSet.getResources().size(); } final ResourceSetImpl virtualResourceSet = new ResourceSetImpl(); for (final Resource physicalResource : physicalResourceSet.getResources()) { if (physicalResource.getContents().size() == 0) { continue; } final EObject eObject = physicalResource.getContents().get(0); final EPackage ePackage = EPackage.class.cast(eObject); if (isContainedInPackageRegistry(ePackage.getNsURI())) { final EPackage registeredPackage = EPackage.Registry.INSTANCE.getEPackage(ePackage.getNsURI()); if (!ePackage.equals(registeredPackage)) { updateRegistryAndLocalCache(ePackage, physicalResource, virtualResourceSet); } continue; } updateRegistryAndLocalCache(ePackage, physicalResource, virtualResourceSet); } }
Source:
public void idle() { Iterator<DispatchAttempt> iterator = sendQueue.iterator(); while (iterator.hasNext()) { DispatchAttempt attempt = iterator.next(); try { doDispatch(attempt); notifyObservers(DispatchResult.success(attempt.event, attempt.address, EventNotificationMethod.EMAIL)); iterator.remove(); } catch (Exception ex) { attempt.attempts++; if (attempt.attempts >= ATTEMPTS) { notifyObservers(DispatchResult.failure(attempt.event, attempt.address, EventNotificationMethod.EMAIL, ex.getMessage())); iterator.remove(); } } } }

Target:
public void idle() { Iterator<DispatchAttempt> iterator = sendQueue.iterator(); while (iterator.hasNext()) { DispatchAttempt attempt = iterator.next(); try { doDispatch(attempt); notifyObservers(DispatchResult.success(attempt.event, attempt.address, EventNotificationMethod.EMAIL)); iterator.remove(); } catch (Exception ex) { attempt.retries++; if (attempt.retries >= retries) { notifyObservers(DispatchResult.failure(attempt.event, attempt.address, EventNotificationMethod.EMAIL, ex.getMessage())); iterator.remove(); } } } }
Source:
public ContentAuditLogExecutorImpl() { final Function<ThreadFactory, ExecutorService> executorServiceSupplier = ( threadFactory ) -> new ThreadPoolExecutor( 0, Runtime.getRuntime().availableProcessors(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>( 100 ) ); this.simpleExecutor = new SimpleExecutor( executorServiceSupplier, "content-audit-log-thread-%d", e -> LOG.error( "Audit log failed", e ) ); }

Target:
public ContentAuditLogExecutorImpl() { final Function<ThreadFactory, ExecutorService> executorServiceSupplier = ( threadFactory ) -> new ThreadPoolExecutor( 0, Runtime.getRuntime().availableProcessors(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>( 100 ), threadFactory, new ThreadPoolExecutor.CallerRunsPolicy() ); this.simpleExecutor = new SimpleExecutor( executorServiceSupplier, "content-audit-log-thread-%d", e -> LOG.error( "Audit log failed", e ) ); }
Source:
public OAuth2AuthorizeRespDTO authorize(OAuth2AuthorizeReqDTO oAuth2AuthorizeReqDTO) { if (log.isDebugEnabled()) { log.debug("Authorization Request received for user : " + oAuth2AuthorizeReqDTO.getUsername() + ", Client ID : " + oAuth2AuthorizeReqDTO.getConsumerKey() + ", Authorization Response Type : " + oAuth2AuthorizeReqDTO.getResponseType() + ", Requested callback URI : " + oAuth2AuthorizeReqDTO.getCallbackUrl() + ", Requested Scope : " + OAuth2Util.buildScopeString( oAuth2AuthorizeReqDTO.getScopes())); } try { AuthorizationHandlerManager authzHandlerManager = AuthorizationHandlerManager.getInstance(); OAuth2AuthorizeRespDTO oAuth2AuthorizeRespDTO = authzHandlerManager.handleAuthorization(oAuth2AuthorizeReqDTO); oAuth2AuthorizeRespDTO.setTokenType(BEARER_TOKEN_TYPE); return oAuth2AuthorizeRespDTO; } catch (Exception e) { log.error("Error occurred when processing the authorization request. " + "Returning an error back to client.", e); OAuth2AuthorizeRespDTO authorizeRespDTO = new OAuth2AuthorizeRespDTO(); authorizeRespDTO.setErrorCode(OAuth2ErrorCodes.SERVER_ERROR); authorizeRespDTO.setErrorMsg("Error occurred when processing the authorization " + "request. Returning an error back to client."); authorizeRespDTO.setCallbackURI(oAuth2AuthorizeReqDTO.getCallbackUrl()); return authorizeRespDTO; } }

Target:
public OAuth2AuthorizeRespDTO authorize(OAuth2AuthorizeReqDTO oAuth2AuthorizeReqDTO) { if (log.isDebugEnabled()) { log.debug("Authorization Request received for user : " + oAuth2AuthorizeReqDTO.getUsername() + ", Client ID : " + oAuth2AuthorizeReqDTO.getConsumerKey() + ", Authorization Response Type : " + oAuth2AuthorizeReqDTO.getResponseType() + ", Requested callback URI : " + oAuth2AuthorizeReqDTO.getCallbackUrl() + ", Requested Scope : " + OAuth2Util.buildScopeString( oAuth2AuthorizeReqDTO.getScopes())); } try { AuthorizationHandlerManager authzHandlerManager = AuthorizationHandlerManager.getInstance(); return authzHandlerManager.handleAuthorization(oAuth2AuthorizeReqDTO); } catch (Exception e) { log.error("Error occurred when processing the authorization request. " + "Returning an error back to client.", e); OAuth2AuthorizeRespDTO authorizeRespDTO = new OAuth2AuthorizeRespDTO(); authorizeRespDTO.setErrorCode(OAuth2ErrorCodes.SERVER_ERROR); authorizeRespDTO.setErrorMsg("Error occurred when processing the authorization " + "request. Returning an error back to client."); authorizeRespDTO.setCallbackURI(oAuth2AuthorizeReqDTO.getCallbackUrl()); return authorizeRespDTO; } }
Source:
public StreamingOutput getShield(@PathParam("id") int branchId) { Optional<RepositoryState> state = stateService.getRepositoryState(branchId); if (!state.isPresent()) { throw new IllegalArgumentException(String.format("No state for id %d", branchId)); } final String path; if (state.get().getLastBuild().isPresent()) { path = pickImage(state.get().getLastBuild().get().getState()); } else { path = "/shields/build-???-lightgrey.png"; } return new StreamingOutput() { @Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { InputStream imageStream = getClass().getResource(path).openStream(); BufferedImage image = ImageIO.read(imageStream); ImageIO.write(image, "png", outputStream); } }; }

Target:
public StreamingOutput getShield(@PathParam("id") int branchId) { Optional<RepositoryState> state = stateService.getRepositoryState(branchId); if (!state.isPresent()) { throw new IllegalArgumentException(String.format("No state for id %d", branchId)); } final String path; if (state.get().getLastBuild().isPresent()) { path = pickImage(state.get().getLastBuild().get().getState()); } else { path = "shields/build-???-lightgrey.png"; } return new StreamingOutput() { @Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { ByteStreams.copy(Resources.getResource(path).openStream(), outputStream); } }; }
Source:
public void setFeatureState(FeatureState featureState) { featureStateProducer.send(featureState.getFeature(), wrapperForFeatureState(featureState)); }

Target:
public void setFeatureState(FeatureState featureState) { FeatureStateStorageWrapper storageWrapper = wrapperForFeatureState(featureState); featureStateProducer.send(featureState.getFeature(), storageWrapper); handleUpdate(featureState.getFeature().name(), storageWrapper); }
Source:
private static void checkProcessResult(IProcess process) throws DebugException { boolean isTerminated = process.isTerminated(); if (!isTerminated) { String output = getOutput(process); Object[] errorInfo = { process.getAttribute(IProcess.ATTR_CMDLINE), output }; String errorMessage = NLS.bind("Process not finished.\n Command line arguments: {0}\nOutput: {1}", errorInfo); IllegalStateException exception = new IllegalStateException(errorMessage); LaunchingPlugin.log(exception); } else { int exitCode = process.getExitValue(); if (exitCode != 0) { String output = getOutput(process); Object[] errorInfo = { process.getAttribute(IProcess.ATTR_CMDLINE), Integer.valueOf(exitCode), output }; String errorMessage = NLS.bind("Process returned with error code \"{0}\".Command line arguments: {1}\n Output: {2}", errorInfo); IllegalStateException exception = new IllegalStateException(errorMessage); LaunchingPlugin.log(exception); } } }

Target:
private static void checkProcessResult(IProcess process) throws DebugException { boolean isTerminated = process.isTerminated(); if (!isTerminated) { String output = getOutput(process); Object[] errorInfo = { process.getAttribute(IProcess.ATTR_CMDLINE), output }; String errorMessage = NLS.bind("Process not finished.\n Command line arguments: {0}\nOutput: {1}", errorInfo); IllegalStateException exception = new IllegalStateException(errorMessage); LaunchingPlugin.log(exception); } else { int exitCode = process.getExitValue(); if (exitCode != 0) { String output = getOutput(process); Object[] errorInfo = { Integer.valueOf(exitCode), process.getAttribute(IProcess.ATTR_CMDLINE), output }; String errorMessage = NLS.bind("Process returned with error code \"{0}\".\nCommand line arguments: {1}\nOutput: {2}", errorInfo); IllegalStateException exception = new IllegalStateException(errorMessage); LaunchingPlugin.log(exception); } } }
Source:
@Test void testCountEqualsDeep() throws SqlParseException { SqlNode countExpression = parseExpression("count(a)"); SqlNode countDistinctExpression = parseExpression("count(distinct a)"); assertThat("count(a) doesn't equals count(a)", countExpression.equalsDeep(parseExpression("count(a)"), Litmus.IGNORE)); assertThat("count(distinct a) doesn't equals count(distinct a)", countDistinctExpression.equalsDeep(parseExpression("count(distinct a)"), Litmus.IGNORE)); assertThat("count(distinct a) equals count(a), unexpected", !countDistinctExpression.equalsDeep(countExpression, Litmus.IGNORE)); }

Target:
@Test void testCountEqualsDeep() throws SqlParseException { assertEqualsDeep("count(a)", "count(a)", true); assertEqualsDeep("count(distinct a)", "count(distinct a)", true); assertEqualsDeep("count(distinct a)", "count(a)", false); }
Source:
private long mapToTxId(DataValueDescriptor dataValue) throws StandardException { if(dataValue instanceof SQLTimestamp) { Timestamp ts = ((SQLTimestamp)dataValue).getTimestamp(null); SpliceLogUtils.trace(LOG,"time travel ts=%s", ts.toString()); try { return SIDriver.driver().getTxnStore().getTxnAt(ts.getTime()); } catch (IOException e) { throw Exceptions.parseException(e); } }else if(dataValue instanceof SQLTinyint || dataValue instanceof SQLSmallint || dataValue instanceof SQLInteger || dataValue instanceof SQLLongint) { return dataValue.getLong(); }else { throw StandardException.newException(SQLState.NOT_IMPLEMENTED); } }

Target:
private long mapToTxId(DataValueDescriptor dataValue) throws StandardException { if(dataValue instanceof SQLTimestamp) { Timestamp ts = ((SQLTimestamp)dataValue).getTimestamp(null); SpliceLogUtils.trace(LOG,"time travel ts=%s", ts.toString()); try { return SIDriver.driver().getTxnStore().getTxnAt(ts.getTime()); } catch (IOException e) { throw Exceptions.parseException(e); } }else if(dataValue instanceof SQLTinyint || dataValue instanceof SQLSmallint || dataValue instanceof SQLInteger || dataValue instanceof SQLLongint) { return dataValue.getLong(); }else { throw StandardException.newException(SQLState.NOT_IMPLEMENTED, dataValue.getClass().getSimpleName() + " can not be used with time travel query"); } }
Source:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); app = (WikipediaApp)getActivity().getApplicationContext(); adapter = new RecentSearchesAdapter(getActivity(), null, true); recentSearchesList.setAdapter(adapter); recentSearchesList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RecentSearch entry = (RecentSearch) view.getTag(); app.getBus().post(new ShowTitleSearchEvent(entry.getText())); } }); getActivity().getSupportLoaderManager().initLoader(0, null, this); getActivity().getSupportLoaderManager().restartLoader(0, null, this); }

Target:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); adapter = new RecentSearchesAdapter(getActivity(), null, true); recentSearchesList.setAdapter(adapter); recentSearchesList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RecentSearch entry = (RecentSearch) view.getTag(); searchFragment.switchToTitleSearch(entry.getText()); } }); getActivity().getSupportLoaderManager().initLoader(0, null, this); getActivity().getSupportLoaderManager().restartLoader(0, null, this); }
Source:
public void edit(VolumeBrickModel object) { table.setRowData(new ArrayList<ListModel>()); table.edit(object.getBricks()); Driver.driver.edit(object); }

Target:
public void edit(VolumeBrickModel object) { table.edit(object.getBricks()); Driver.driver.edit(object); }
Source:
public void onPlanStatusChange(PlanInfo planInfo) { Status status = planInfo.getStatus(); if (status.equals(Status.COMPLETED)) { done(planInfo.getId()); } else if (status.equals(Status.CANCELED) || status.equals(Status.FAILED)) { stop(planInfo.getId(), status, planInfo.getErrorMessage()); } }

Target:
public void onPlanStatusChange(PlanInfo planInfo) { Status status = planInfo.getStatus(); switch (status) { case COMPLETED: done(planInfo.getId()); break; case CANCELED: case FAILED: stop(planInfo.getId(), status, planInfo.getErrorMessage()); break; default: break; } }
Source:
protected void updateIndexedObjectsWithQueries(List<?> queries, List<IndexedObjectInformation> indexedObjectInformations) { for (int i = 0; i < queries.size(); i++) { Object query = queries.get(0); if (query instanceof IndexQuery) { IndexQuery indexQuery = (IndexQuery) query; Object queryObject = indexQuery.getObject(); if (queryObject != null) { updateIndexedObject(queryObject, indexedObjectInformations.get(i)); } } } }

Target:
protected void updateIndexedObjectsWithQueries(List<?> queries, List<IndexedObjectInformation> indexedObjectInformations) { for (int i = 0; i < queries.size(); i++) { Object query = queries.get(i); if (query instanceof IndexQuery) { IndexQuery indexQuery = (IndexQuery) query; Object queryObject = indexQuery.getObject(); if (queryObject != null) { updateIndexedObject(queryObject, indexedObjectInformations.get(i)); } } } }
Source:
public void should_not_fail_if_a_profile_with_same_name_is_present() throws SQLException { insertQualityGate(SONAR_WAY_OUTDATED_QUALITY_GATE, false); insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); underTest.execute(); assertThat(db.countRowsOfTable("quality_gates")).isEqualTo(2); }

Target:
public void should_not_fail_if_a_profile_with_same_name_is_present() throws SQLException { insertQualityGate(SONAR_WAY_OUTDATED_QUALITY_GATE, false); insertQualityGate(SONARQUBE_WAY_QUALITY_GATE, false); underTest.execute(); assertQualityGates( tuple(SONAR_WAY_OUTDATED_QUALITY_GATE, false, new Date(PAST), new Date(PAST)), tuple(SONAR_WAY_OUTDATED_QUALITY_GATE + " " + NOW, false, new Date(PAST), new Date(NOW)) ); }
Source:
public void render(HolopadTileEntity tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) { super.render(tileEntityIn, x, y, z, partialTicks, destroyStage); if(tileEntityIn.hasCard()) { ItemStack item = tileEntityIn.getHoloItem(); float f = (float) tileEntityIn.innerRotation + partialTicks; float scale = 0.8F; GlStateManager.pushMatrix(); GlStateManager.translated((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); GlStateManager.rotated(f / 20.0F * 57.295776F, 0.0F, 1.0F, 0.0F); Minecraft.getInstance().getItemRenderer().renderItem(item, ItemCameraTransforms.TransformType.GROUND); GlStateManager.popMatrix(); } }

Target:
public void render(HolopadTileEntity tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) { super.render(tileEntityIn, x, y, z, partialTicks, destroyStage); if(tileEntityIn.hasCard()) { ItemStack item = tileEntityIn.getHoloItem(); float f = (float) tileEntityIn.innerRotation + partialTicks; GlStateManager.pushMatrix(); GlStateManager.translatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); GlStateManager.rotatef(f / 20.0F * 57.295776F, 0.0F, 1.0F, 0.0F); Minecraft.getInstance().getItemRenderer().renderItem(item, ItemCameraTransforms.TransformType.GROUND); GlStateManager.popMatrix(); } }
Source:
public Page getOutput() { if (!blocked.isDone() || state != State.FINISHING) { return null; } if (!statisticAggregation.isFinished()) { Page aggregationOutput = statisticAggregation.getOutput(); if (aggregationOutput == null) { return null; } int positionCount = aggregationOutput.getPositionCount(); Block[] outputBlocks = new Block[types.size()]; for (int channel = 0; channel < types.size(); channel++) { if (channel < WRITER_CHANNELS) { outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount); } else { outputBlocks[channel] = aggregationOutput.getBlock(channel - 2); } } return new Page(positionCount, outputBlocks); } Page fragmentsPage = createFragmentsPage(); int positionCount = fragmentsPage.getPositionCount(); Block[] outputBlocks = new Block[types.size()]; for (int channel = 0; channel < types.size(); channel++) { if (channel < WRITER_CHANNELS) { outputBlocks[channel] = fragmentsPage.getBlock(channel); } else { outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount); } } state = State.FINISHED; return new Page(positionCount, outputBlocks); }

Target:
public Page getOutput() { if (state != State.FINISHING || !blocked.isDone()) { return null; } if (!statisticAggregationOperator.isFinished()) { Page aggregationOutput = statisticAggregationOperator.getOutput(); if (aggregationOutput == null) { return null; } int positionCount = aggregationOutput.getPositionCount(); Block[] outputBlocks = new Block[types.size()]; for (int channel = 0; channel < types.size(); channel++) { if (channel < WRITER_CHANNELS) { outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount); } else { outputBlocks[channel] = aggregationOutput.getBlock(channel - 2); } } return new Page(positionCount, outputBlocks); } Page fragmentsPage = createFragmentsPage(); int positionCount = fragmentsPage.getPositionCount(); Block[] outputBlocks = new Block[types.size()]; for (int channel = 0; channel < types.size(); channel++) { if (channel < WRITER_CHANNELS) { outputBlocks[channel] = fragmentsPage.getBlock(channel); } else { outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount); } } state = State.FINISHED; return new Page(positionCount, outputBlocks); }
Source:
private void generateNodeId() { UUID serverId; if (serverConfig.get("--node-id") != null) { serverId = UuidUtils.fromBase64(getServerConfig(String.class, "--node-id")); } else { serverId = UUID.randomUUID(); } String currentId = getDataStore().get(NODE_ID_RECORD); if (currentId == null) { String idString = UuidUtils.asBase64(serverId); log.info("No Node Id, setting to new Id={}", idString); getDataStore().put(NODE_ID_RECORD, idString); } else { log.info("Node Id = {}", currentId); } }

Target:
private void generateNodeId() { Optional<String> maybeNodeIdRecord = Optional.ofNullable(getDataStore().get(NODE_ID_RECORD)); if (maybeNodeIdRecord.isPresent()) { log.info("Node Id = {}", maybeNodeIdRecord.get()); } else { UUID serverId = Optional.ofNullable(serverConfig.get("--node-id")) .map(sid -> UuidUtils.fromBase64(getServerConfig(String.class, "--node-id"))) .orElse(UUID.randomUUID()); String idString = UuidUtils.asBase64(serverId); log.info("No Node Id, setting to new Id={}", idString); getDataStore().put(NODE_ID_RECORD, idString); } }
Source:
public void run() throws MetaException { while (true) { try { command.process(); break; } catch (Exception e) { LOG.info("retried / max : / {}", currentRetries, maxRetries); if (currentRetries >= maxRetries) { LOG.error("failed to execute Command :: ", e); throw new MetaException(e.getMessage()); } currentRetries++; try { Thread.sleep(sleepInterval); } catch (InterruptedException e1) { String msg = "error waiting for next retry " + currentRetries; LOG.error(msg, e1); throw new MetaException(msg); } } } }

Target:
public void run() throws MetaException { while (true) { try { command.process(); break; } catch (Exception e) { LOG.info( "Attempting to acquire the DB log notification lock: " + currentRetries + " out of " + maxRetries + " retries", e); if (currentRetries >= maxRetries) { String message = "Couldn't acquire the DB log notification lock because we reached the maximum" + " # of retries: retries. If this happens too often, then is recommended to " + "increase the maximum number of retries on the" + " hive.notification.sequence.lock.max.retries configuration"; LOG.error(message, e); throw new MetaException(message + " :: " + e.getMessage()); } currentRetries++; try { Thread.sleep(sleepInterval); } catch (InterruptedException e1) { String msg = "Couldn't acquire the DB notification log lock on " + currentRetries + " retry, because the following error: "; LOG.error(msg, e1); throw new MetaException(msg + e1.getMessage()); } } } }