auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void setProperty(PGProperty property, String value) { if (value == null) { return; } switch (property) { case PG_HOST: <START> serverNames = value.split(","); <END> break; case PG_PORT: String[] ps = value.split(","); portNumbers = new int[ps.length]; for (int i = 0 ; i < ps.length; i++) { try { portNumbers[i] = Integer.parseInt(ps[i]); } catch (NumberFormatException e) { portNumbers[i] = 0; } } break; case PG_DBNAME: databaseName = value; break; case USER: user = value; break; case PASSWORD: password = value; break; default: properties.setProperty(property.getName(), value); } }</code><technical_language>This delegate setServerNames(...) direct assignment member variable</technical_language>

Target:
public void setProperty(PGProperty property, String value) { if (value == null) { return; } switch (property) { case PG_HOST: setServerNames(value.split(",")); break; case PG_PORT: String[] ps = value.split(","); int[] ports = new int[ps.length]; for (int i = 0 ; i < ps.length; i++) { try { ports[i] = Integer.parseInt(ps[i]); } catch (NumberFormatException e) { ports[i] = 0; } } setPortNumbers(ports); break; case PG_DBNAME: setDatabaseName(value); break; case USER: setUser(value); break; case PASSWORD: setPassword(value); break; default: properties.setProperty(property.getName(), value); } }
Source:
<code><START> public java.security.cert.X509Certificate[] getAcceptedIssuers() { <END> return null; }</code><technical_language>Style-nit: prefer import names short class name instead</technical_language>

Target:
public X509Certificate[] getAcceptedIssuers() { return null; }
Source:
<code>@Override public void onTimeout() { synchronized (GridDhtLockFuture.this) { if (log.isDebugEnabled() || timeout >= longOpDumpTimeout) { <START> String msg = "Timed out waiting for lock response, pending locks: " + dump(); <END> if (log.isDebugEnabled()) log.debug(msg); else log.warning(msg); } timedOut = true; pendingLocks.clear(); clear(); } boolean releaseLocks = !(inTx() && cctx.tm().deadlockDetectionEnabled()); onComplete(false, false, releaseLocks); }</code><technical_language>dispose of string concatentation StringBuffer defined in dump()</technical_language>

Target:
@Override public void onTimeout() { long longOpsDumpTimeout = cctx.tm().longOperationsDumpTimeout(); synchronized (GridDhtLockFuture.this) { if (log.isDebugEnabled() || timeout >= longOpsDumpTimeout) { String msg = dumpPendingLocks(); if (log.isDebugEnabled()) log.debug(msg); else log.warning(msg); } timedOut = true; pendingLocks.clear(); clear(); } boolean releaseLocks = !(inTx() && cctx.tm().deadlockDetectionEnabled()); onComplete(false, false, releaseLocks); }
Source:
<code>private CompletableFuture<Void> handleNonTxWriteCommand(InvocationContext ctx, WriteCommand command) throws Throwable { if (trace) log.tracef("handleNonTxWriteCommand for command %s, topology id %d", command, command.getTopologyId()); if (isLocalOnly(command)) { return ctx.continueInvocation(); } updateTopologyId(command); if (!ctx.isOriginLocal()) { return ctx.continueInvocation(); } int commandTopologyId = command.getTopologyId(); Object localResult; try { <START> localResult = ctx.forkInvocationSync(command); <END> return ctx.shortCircuit(localResult); } catch (CacheException e) { Throwable ce = e; while (ce instanceof RemoteException) { ce = ce.getCause(); } if (!(ce instanceof OutdatedTopologyException) && !(ce instanceof SuspectException)) throw e; int currentTopologyId = currentTopologyId(); if (trace) log.tracef("Retrying command because of topology change, current topology is %d: %s", currentTopologyId, command); int newTopologyId = Math.max(currentTopologyId, commandTopologyId + 1); command.setTopologyId(newTopologyId); waitForTransactionData(newTopologyId); command.addFlag(Flag.COMMAND_RETRY); return handleNonTxWriteCommand(ctx, command); } }</code><technical_language>ctx.shortCircuit(ctx.forkInvocationSync(command)); consistent others thousands :)</technical_language>

Target:
private CompletableFuture<Void> handleNonTxWriteCommand(InvocationContext ctx, WriteCommand command) throws Throwable { if (trace) log.tracef("handleNonTxWriteCommand for command %s, topology id %d", command, command.getTopologyId()); if (isLocalOnly(command)) { return ctx.continueInvocation(); } updateTopologyId(command); if (!ctx.isOriginLocal()) { return ctx.continueInvocation(); } int commandTopologyId = command.getTopologyId(); try { return ctx.shortCircuit(ctx.forkInvocationSync(command)); } catch (CacheException e) { Throwable ce = e; while (ce instanceof RemoteException) { ce = ce.getCause(); } if (!(ce instanceof OutdatedTopologyException) && !(ce instanceof SuspectException)) throw e; int currentTopologyId = currentTopologyId(); if (trace) log.tracef("Retrying command because of topology change, current topology is %d: %s", currentTopologyId, command); int newTopologyId = Math.max(currentTopologyId, commandTopologyId + 1); command.setTopologyId(newTopologyId); waitForTransactionData(newTopologyId); command.addFlag(Flag.COMMAND_RETRY); return handleNonTxWriteCommand(ctx, command); } }
Source:
<code>public GeometricFillTool(Context context, ToolType toolType) { super(context, toolType); setRotationEnabled(ROTATION_ENABLED); setRespectImageBounds(RESPECT_IMAGE_BOUNDS); if (baseShape == null) { baseShape = BaseShape.RECTANGLE; } <START> if (shapeOutlineWidth == 0) { <END> shapeOutlineWidth = 25; } shapeDrawType = ShapeDrawType.FILL; createOverlayBitmap(); createAndSetBitmap(); }</code><technical_language>do check for 0? (I a specific value, this <=0? in constructor, set shapeOutlineWidth 25 there. better: hardcode magic numbers, a DEFAULT_SHAPE_OUTLINE_WIDTH constant define 25</technical_language>

Target:
public GeometricFillTool(Context context, ToolType toolType) { super(context, toolType); setRotationEnabled(ROTATION_ENABLED); setRespectImageBounds(RESPECT_IMAGE_BOUNDS); if (baseShape == null) { baseShape = BaseShape.RECTANGLE; } shapeDrawType = ShapeDrawType.FILL; createOverlayBitmap(); createAndSetBitmap(); }
Source:
<code>public void testAddElementsInOrder() { TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR); List<Integer> list = new ArrayList<>(); <START> double[] quantile = {0.0001, 0.0200, 0.0300, 0.04000, 0.0500, 0.1000, 0.2000, 0.3000, 0.4000, 0.5000, 0.6000, 0.7000, 0.8000, <END> 0.9000, 0.9500, 0.9600, 0.9700, 0.9800, 0.9999}; for (int i = 0; i < NUMBER_OF_ENTRIES; i++) { tDigest.add(i); list.add(i); } for (int i = 0; i < quantile.length; i++) { assertDiscreteWithinBound(quantile[i], STANDARD_ERROR, list, tDigest); } }</code><technical_language>this a constant put in line</technical_language>

Target:
public void testAddElementsInOrder() { TDigest tDigest = createTDigest(STANDARD_COMPRESSION_FACTOR); List<Integer> list = new ArrayList<>(); for (int i = 0; i < NUMBER_OF_ENTRIES; i++) { tDigest.add(i); list.add(i); } for (int i = 0; i < quantile.length; i++) { assertDiscreteWithinBound(quantile[i], STANDARD_ERROR, list, tDigest); } }
Source:
<code>public void run() { synchronized(JmsOutboundGateway.this.lifeCycleMonitor) { if (System.currentTimeMillis() - lastSend > idleReplyContainerTimeout && replies.size() == 0) { if (logger.isDebugEnabled()) { logger.debug(getComponentName() + ": Stopping idle reply container."); } <START> if (replyContainer.isRunning()) { <END> replyContainer.stop(); idleTask.cancel(false); idleTask = null; } } } }</code><technical_language>previous DEBUG moved here: sense Stopping idle reply container. if stop this isRunning() condition</technical_language>

Target:
public void run() { synchronized(JmsOutboundGateway.this.lifeCycleMonitor) { if (System.currentTimeMillis() - lastSend > idleReplyContainerTimeout && replies.size() == 0) { if (replyContainer.isRunning()) { if (logger.isDebugEnabled()) { logger.debug(getComponentName() + ": Stopping idle reply container."); } replyContainer.stop(); idleTask.cancel(false); idleTask = null; } } } }
Source:
<code>public void onChildMoved(DataSnapshot snapshot, String previousChildKey) { int oldIndex = getIndexForKey(snapshot.getKey()); mSnapshots.remove(oldIndex); <START> int newIndex = previousChildKey == null ? 0 : getIndexForKey(previousChildKey) + 1; <END> mSnapshots.add(newIndex, snapshot); notifyChangedListeners(OnChangedListener.EventType.MOVED, newIndex, oldIndex); }</code><technical_language>Please put parentheses (getIndexForKey(previousChildKey) + 1). behavior is same, intent more explicit</technical_language>

Target:
public void onChildMoved(DataSnapshot snapshot, String previousChildKey) { int oldIndex = getIndexForKey(snapshot.getKey()); mSnapshots.remove(oldIndex); int newIndex = previousChildKey == null ? 0 : (getIndexForKey(previousChildKey) + 1); mSnapshots.add(newIndex, snapshot); notifyChangedListeners(OnChangedListener.EventType.MOVED, newIndex, oldIndex); }
Source:
<code>public LookupRuntimeProvider getLookupRuntimeProvider(LookupContext context) { if (lookupFunctionClass != null) { try { Class<?> clazz = Class.forName(lookupFunctionClass); Object udtf = InstantiationUtil.instantiate(clazz); if (udtf instanceof TableFunction) { return TableFunctionProvider.of((TableFunction) udtf); } else { return AsyncTableFunctionProvider.of((AsyncTableFunction) udtf); } } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Could not instantiate class: " + lookupFunctionClass); } } int[] lookupIndices = Arrays.stream(context.getKeys()) .mapToInt(k -> k[0]) .toArray(); Map<Row, List<Row>> mapping = new HashMap<>(); Collection<Row> rows; if (allPartitions.equals(Collections.EMPTY_LIST)) { rows = data.getOrDefault(Collections.EMPTY_MAP, Collections.EMPTY_LIST); } else { rows = new ArrayList<>(); <START> allPartitions.stream() <END> .forEach(key -> rows.addAll(data.getOrDefault(key, new ArrayList<Row>()))); } rows.forEach(record -> { Row key = Row.of(Arrays.stream(lookupIndices) .mapToObj(record::getField) .toArray()); List<Row> list = mapping.get(key); if (list != null) { list.add(record); } else { list = new ArrayList<>(); list.add(record); mapping.put(key, list); } }); if (isAsync) { return AsyncTableFunctionProvider.of(new AsyncTestValueLookupFunction(mapping)); } else { return TableFunctionProvider.of(new TestValuesLookupFunction(mapping)); } }</code><technical_language>nit: .stream() is unnecessary</technical_language>

Target:
public LookupRuntimeProvider getLookupRuntimeProvider(LookupContext context) { if (lookupFunctionClass != null) { try { Class<?> clazz = Class.forName(lookupFunctionClass); Object udtf = InstantiationUtil.instantiate(clazz); if (udtf instanceof TableFunction) { return TableFunctionProvider.of((TableFunction) udtf); } else { return AsyncTableFunctionProvider.of((AsyncTableFunction) udtf); } } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Could not instantiate class: " + lookupFunctionClass); } } int[] lookupIndices = Arrays.stream(context.getKeys()) .mapToInt(k -> k[0]) .toArray(); Map<Row, List<Row>> mapping = new HashMap<>(); Collection<Row> rows; if (allPartitions.equals(Collections.EMPTY_LIST)) { rows = data.getOrDefault(Collections.EMPTY_MAP, Collections.EMPTY_LIST); } else { rows = new ArrayList<>(); allPartitions.forEach(key -> rows.addAll(data.getOrDefault(key, new ArrayList<>()))); } rows.forEach(record -> { Row key = Row.of(Arrays.stream(lookupIndices) .mapToObj(record::getField) .toArray()); List<Row> list = mapping.get(key); if (list != null) { list.add(record); } else { list = new ArrayList<>(); list.add(record); mapping.put(key, list); } }); if (isAsync) { return AsyncTableFunctionProvider.of(new AsyncTestValueLookupFunction(mapping)); } else { return TableFunctionProvider.of(new TestValuesLookupFunction(mapping)); } }
Source:
<code>@Test public void discoverLanguage() throws Exception { final FileObject location = resourceService.resolve("res:"); final Iterable<ILanguageComponent> languages = languageDiscoveryService.discover(languageDiscoveryService.request(location)); assertEquals(1, Iterables.size(languages)); final ILanguageComponent component = Iterables.get(languages, 0); final ILanguageImpl impl = Iterables.get(component.contributesTo(), 0); final ILanguage language = impl.belongsTo(); assertEquals("Entity", language.name()); assertEquals(resourceService.resolve("res:Entity"), component.location()); final IdentificationFacet identificationFacet = impl.facet(IdentificationFacet.class); assertTrue(identificationFacet.identify(resourceService.resolve("ram:/ final SyntaxFacet syntaxFacet = impl.facet(SyntaxFacet.class); assertEquals(resourceService.resolve("res:Entity/target/metaborg/sdf.tbl"), syntaxFacet.parseTable); assertIterableEquals(syntaxFacet.startSymbols, "Start"); <START> final DynamicClassLoadingFacet strategoFacet = impl.facet(DynamicClassLoadingFacet.class); <END> assertIterableEquals(strategoFacet.ctreeFiles, resourceService.resolve("res:Entity/target/metaborg/stratego.ctree")); assertIterableEquals(strategoFacet.jarFiles, resourceService.resolve("res:Entity/target/metaborg/stratego-javastrat.jar")); final AnalysisFacet analysisFacet = impl.facet(AnalysisFacet.class); assertEquals("editor-analyze", analysisFacet.strategyName); }</code><technical_language>Rename variable name</technical_language>

Target:
@Test public void discoverLanguage() throws Exception { final FileObject location = resourceService.resolve("res:"); final Iterable<ILanguageComponent> languages = languageDiscoveryService.discover(languageDiscoveryService.request(location)); assertEquals(1, Iterables.size(languages)); final ILanguageComponent component = Iterables.get(languages, 0); final ILanguageImpl impl = Iterables.get(component.contributesTo(), 0); final ILanguage language = impl.belongsTo(); assertEquals("Entity", language.name()); assertEquals(resourceService.resolve("res:Entity"), component.location()); final IdentificationFacet identificationFacet = impl.facet(IdentificationFacet.class); assertTrue(identificationFacet.identify(resourceService.resolve("ram:/ final SyntaxFacet syntaxFacet = impl.facet(SyntaxFacet.class); assertEquals(resourceService.resolve("res:Entity/target/metaborg/sdf.tbl"), syntaxFacet.parseTable); assertIterableEquals(syntaxFacet.startSymbols, "Start"); final DynamicClassLoadingFacet dynamicClassLoadingFacet = impl.facet(DynamicClassLoadingFacet.class); final StrategoRuntimeFacet strategoRuntimeFacet = impl.facet(StrategoRuntimeFacet.class); assertIterableEquals(strategoRuntimeFacet.ctreeFiles, resourceService.resolve("res:Entity/target/metaborg/stratego.ctree")); assertIterableEquals(dynamicClassLoadingFacet.jarFiles, resourceService.resolve("res:Entity/target/metaborg/stratego-javastrat.jar")); final AnalysisFacet analysisFacet = impl.facet(AnalysisFacet.class); assertEquals("editor-analyze", analysisFacet.strategyName); }
Source:
<code>public void predictFunctionTest() throws InterruptedException, URISyntaxException { URL resource = PredictStreamProcessorTestCase.class.getResource("/test-model"); String modelStorageLocation = new File(resource.toURI()).getAbsolutePath(); SiddhiManager siddhiManager = new SiddhiManager(); String inputStream = "define stream InputStream " + "(NumPregnancies double, PG2 double, DBP double, TSFT double, SI2 double, BMI double, DPF double, Age double);"; String query = "@info(name = 'query1') " + "from InputStream#ml:predict('"+ modelStorageLocation +"') " + "select * " + "insert into outputStream ;"; ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inputStream + query); executionPlanRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); if (inEvents != null) { Assert.assertEquals(0.9176214029655854, inEvents[0].getData(8)); } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("InputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{6, 148, 72, 35, 0, 33.6, 0.627, 50}); Thread.sleep(1000); <START> executionPlanRuntime.shutdown(); <END> }</code><technical_language>need assert if a result</technical_language>

Target:
public void predictFunctionTest() throws InterruptedException, URISyntaxException { URL resource = PredictStreamProcessorTestCase.class.getResource("/test-model"); String modelStorageLocation = new File(resource.toURI()).getAbsolutePath(); SiddhiManager siddhiManager = new SiddhiManager(); String inputStream = "define stream InputStream " + "(NumPregnancies double, PG2 double, DBP double, TSFT double, SI2 double, BMI double, DPF double, Age double);"; String query = "@info(name = 'query1') " + "from InputStream#ml:predict('"+ modelStorageLocation +"') " + "select * " + "insert into outputStream ;"; ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inputStream + query); executionPlanRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); eventArrived = true; if (inEvents != null) { Assert.assertEquals(0.9176214029655854, inEvents[0].getData(8)); } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("InputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{6, 148, 72, 35, 0, 33.6, 0.627, 50}); Thread.sleep(1000); junit.framework.Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }
Source:
<code>public Message<?> fromSyslog(Message<?> message) throws Exception { boolean isMap = message.getPayload() instanceof Map; Map<String, ?> map; Object originalContent; if (!isMap) { Assert.isInstanceOf(byte[].class, message.getPayload(), "Only byte[] and Map payloads are supported"); map = this.parser.parse(new String(((byte[]) message.getPayload()), this.charset), 0, false); originalContent = message.getPayload(); } else { map = (Map<String, ?>) message.getPayload(); originalContent = map.get(LogField.UNDECODED); if (originalContent == null) { originalContent = map; } } <START> AbstractIntegrationMessageBuilder<Object> builder = this.getMessageBuilderFactory().withPayload( <END> asMap() ? map : originalContent); if (!asMap() && isMap) { builder.copyHeaders(map); } return builder.build(); }</code><technical_language>this. is overhead for methods</technical_language>

Target:
public Message<?> fromSyslog(Message<?> message) throws Exception { boolean isMap = message.getPayload() instanceof Map; Map<String, ?> map; Object originalContent; if (!isMap) { Assert.isInstanceOf(byte[].class, message.getPayload(), "Only byte[] and Map payloads are supported"); map = this.parser.parse(new String(((byte[]) message.getPayload()), this.charset), 0, false); originalContent = message.getPayload(); } else { map = (Map<String, ?>) message.getPayload(); originalContent = map.get(SyslogHeaders.UNDECODED); if (originalContent == null) { originalContent = map; } } AbstractIntegrationMessageBuilder<Object> builder = getMessageBuilderFactory().withPayload( asMap() ? map : originalContent); if (!asMap() && isMap) { builder.copyHeaders(map); } return builder.build(); }
Source:
<code><START> public void addAllInternal(CanonicalizingHashSet<E> set) { <END> map.putAll(set.map); }</code><technical_language>minor: access package-private (in support of method name's Internal suffix :-) ). for addInternal below</technical_language>

Target:
void addAllInternal(CanonicalizingHashSet<E> set) { map.putAll(set.map); }
Source:
<code><START> private static boolean isValidRefExpression(final String s) { <END> if (RefSpec.isWildcard(s)) { if (s.indexOf('*', s.indexOf('*') + 1) >= 0) { return false; } return isValidRefExpression(s.replace('*', 'X')); } else return Repository.isValidRefName(s) || Repository.isValidRefName(Constants.R_HEADS + s) || Repository.isValidRefName(Constants.R_TAGS + s); }</code><technical_language>Ok... isWildcard() searches for '*'. do this anyway, clean this method avoid needless tail recursion altogether: if (s == null) { return false; } String spec = s; int i = spec.indexOf('*'); if (i >= 0) { if (spec.indexOf('*', i+1) >= 0) { return false; // '*' allowed } // replace wildcard arbitrary legal character for checking spec = spec.replace('*', 'X'); } return Repository.isValidRefName(Constants.R_HEADS + spec); I extra check for R_TAGS + s omitted. If spec is invalid for R_HEADS, invalid for R_TAGS. Ditto for check spec itself. If spec is "foo", need prefix R_HEADS anyway. if spec if "foo/bar", checking R_HEADS + "foo/bar" result</technical_language>

Target:
private static boolean isValidRefExpression(final String s) { if (s == null) { return false; } String spec = s; int i = spec.indexOf('*'); if (i >= 0) { if (spec.indexOf('*', i + 1) >= 0) { return false; } spec = spec.replace('*', 'X'); } return Repository.isValidRefName(Constants.R_HEADS + spec); }
Source:
<code>public void deleteFeedbackResponsesForQuestionAndCascade( String feedbackQuestionId, boolean hasResponseRateCheck) { List<FeedbackResponseAttributes> responsesForQuestion = getFeedbackResponsesForQuestion(feedbackQuestionId); Set<String> emails = new HashSet<String>(); for (FeedbackResponseAttributes response : responsesForQuestion) { this.deleteFeedbackResponseAndCascade(response); emails.add(response.giverEmail); } try { <START> if (hasResponseRateCheck) { <END> FeedbackQuestionAttributes question = fqLogic .getFeedbackQuestion(feedbackQuestionId); boolean isInstructor = (question.giverType == FeedbackParticipantType.SELF || question.giverType == FeedbackParticipantType.INSTRUCTORS); for (String email : emails) { boolean hasResponses = checkIfGiverHasResponsesForSession(email, question.feedbackSessionName, question.courseId); if (!hasResponses) { if (isInstructor) { InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(question.courseId, email); fsLogic.deleteInstructorRespondant(instructor.googleId, question.feedbackSessionName, question.courseId); } else { StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, email); fsLogic.deleteStudentRespondant(student.googleId, question.feedbackSessionName, question.courseId); } } } } } catch (InvalidParametersException | EntityDoesNotExistException e) { Assumption.fail("Fail to delete respondant"); } }</code><technical_language>For this condition, block is long. Try reduce block length nesting level reversing condition. e.g. if (!hasResponseRateCheck) { return; }</technical_language>

Target:
public void deleteFeedbackResponsesForQuestionAndCascade( String feedbackQuestionId, boolean hasResponseRateCheck) { List<FeedbackResponseAttributes> responsesForQuestion = getFeedbackResponsesForQuestion(feedbackQuestionId); Set<String> emails = new HashSet<String>(); for (FeedbackResponseAttributes response : responsesForQuestion) { this.deleteFeedbackResponseAndCascade(response); emails.add(response.giverEmail); } if(!hasResponseRateCheck){ return; } try { FeedbackQuestionAttributes question = fqLogic .getFeedbackQuestion(feedbackQuestionId); boolean isInstructor = (question.giverType == FeedbackParticipantType.SELF || question.giverType == FeedbackParticipantType.INSTRUCTORS); for (String email : emails) { boolean hasResponses = hasGiverRespondedForSession(email, question.feedbackSessionName, question.courseId); if (!hasResponses) { if (isInstructor) { fsLogic.deleteInstructorRespondant(email, question.feedbackSessionName, question.courseId); } else { fsLogic.deleteStudentRespondant(email, question.feedbackSessionName, question.courseId); } } } } catch (InvalidParametersException | EntityDoesNotExistException e) { Assumption.fail("Fail to delete respondant"); } }
Source:
<code>public static final void setDarkThemePreferred(boolean preferred){ if (!GTK3) return; <START> OS.gdk_flush(); <END> OS.g_object_set(OS.gtk_settings_get_default(), gtk_application_prefer_dark_theme, preferred, 0); OS.g_object_notify(OS.gtk_settings_get_default(), gtk_application_prefer_dark_theme); }</code><technical_language>I this a difference invoke methods prefix OS static methods class, is other reason this way? (just curious!)</technical_language>

Target:
public static final void setDarkThemePreferred(boolean preferred){ if (!GTK3) return; gdk_flush(); g_object_set(OS.gtk_settings_get_default(), gtk_application_prefer_dark_theme, preferred, 0); g_object_notify(OS.gtk_settings_get_default(), gtk_application_prefer_dark_theme); }
Source:
<code>public void populateCountry(ChatChannelUser chatChannelUser) { if (chatChannelUser.isDisplayed()) { <START> if (chatChannelUser.getCountryFlag().isEmpty()) { <END> chatChannelUser.getPlayer() .ifPresent(player -> { Optional<Image> countryFlag = countryFlagService.loadCountryFlag(player.getCountry()); Platform.runLater(() -> { chatChannelUser.setCountryFlag(countryFlag.orElse(null)); chatChannelUser.setCountryName(i18n.getCountryNameLocalized(player.getCountry())); }); }); } } else { chatChannelUser.setCountryFlag(null); chatChannelUser.setCountryName(null); } }</code><technical_language>early return -> nesting</technical_language>

Target:
public void populateCountry(ChatChannelUser chatChannelUser) { if (chatChannelUser.isDisplayed()) { if (!chatChannelUser.getCountryFlag().isEmpty()) { return; } chatChannelUser.getPlayer() .ifPresent(player -> { Optional<Image> countryFlag = countryFlagService.loadCountryFlag(player.getCountry()); Platform.runLater(() -> { chatChannelUser.setCountryFlag(countryFlag.orElse(null)); chatChannelUser.setCountryName(i18n.getCountryNameLocalized(player.getCountry())); }); }); } else { chatChannelUser.setCountryFlag(null); chatChannelUser.setCountryName(null); } }
Source:
<code>public boolean execute() throws SQLException { parseIfNeeded(); for (int c = 0, sz = parameterTypes.size(); c < sz; ++c) { Type parameterType = parameterTypes.get(c); Object parameterValue = parameterValues.get(c); if (parameterValue != null) { Class<?> targetType = mapSetType(parameterType); try { parameterValue = coerce(parameterValue, parameterType, targetType, Collections.<String, Class<?>>emptyMap(), TimeZone.getDefault(), connection); } catch (SQLException coercionException) { throw new SQLException("Error converting parameter " + c, coercionException); } } parameterValues.set(c, parameterValue); } boolean res = super.executeStatement(name, parameterTypes, parameterValues); if (cursorName != null) { res = super.executeSimple("FETCH ABSOLUTE 0 FROM " + cursorName); } if (wantsGeneratedKeys) { if (generatedKeysResultSet != null && !generatedKeysResultSet.isClosed()) { generatedKeysResultSet.internalClose(); } <START> <END> generatedKeysResultSet = getResultSet(); } return res; }</code><technical_language>This needs remove generatedKeysResultSet activeResultSets list well</technical_language>

Target:
public boolean execute() throws SQLException { parseIfNeeded(); closeResultSets(); for (int c = 0, sz = parameterTypes.size(); c < sz; ++c) { Type parameterType = parameterTypes.get(c); Object parameterValue = parameterValues.get(c); if (parameterValue != null) { Class<?> targetType = mapSetType(parameterType); try { parameterValue = coerce(parameterValue, parameterType, targetType, Collections.<String, Class<?>>emptyMap(), TimeZone.getDefault(), connection); } catch (SQLException coercionException) { throw new SQLException("Error converting parameter " + c, coercionException); } } parameterValues.set(c, parameterValue); } boolean res = super.executeStatement(name, parameterTypes, parameterValues); if (cursorName != null) { res = super.executeSimple("FETCH ABSOLUTE 0 FROM " + cursorName); } if (wantsGeneratedKeys) { generatedKeysResultSet = getResultSet(); } return res; }
Source:
<code>public void handlerAdded(ChannelHandlerContext ctx) { ChannelPipeline cp = ctx.pipeline(); if (cp.get(WebSocketClientProtocolHandshakeHandler.class) == null) { ctx.pipeline().addBefore(ctx.name(), WebSocketClientProtocolHandshakeHandler.class.getName(), new WebSocketClientProtocolHandshakeHandler(handshaker) <START> .handshakeTimeoutMillis(handshakeTimeoutMillis)); <END> } if (cp.get(Utf8FrameValidator.class) == null) { ctx.pipeline().addBefore(ctx.name(), Utf8FrameValidator.class.getName(), new Utf8FrameValidator()); } }</code><technical_language>pass this in additional constructor parameter? need introduce a mutable state</technical_language>

Target:
public void handlerAdded(ChannelHandlerContext ctx) { ChannelPipeline cp = ctx.pipeline(); if (cp.get(WebSocketClientProtocolHandshakeHandler.class) == null) { ctx.pipeline().addBefore(ctx.name(), WebSocketClientProtocolHandshakeHandler.class.getName(), new WebSocketClientProtocolHandshakeHandler(handshaker, handshakeTimeoutMillis)); } if (cp.get(Utf8FrameValidator.class) == null) { ctx.pipeline().addBefore(ctx.name(), Utf8FrameValidator.class.getName(), new Utf8FrameValidator()); } }
Source:
<code>protected final AsyncHandler.State disposed() { if (!delegateTerminated.getAndSet(true)) { <START> delegate().onThrowable(new DisposedException()); <END> } return State.ABORT; }</code><technical_language>DisposedException turned a singleton/constant stacktrace</technical_language>

Target:
protected final AsyncHandler.State disposed() { if (!delegateTerminated.getAndSet(true)) { DisposedException disposed = sharedDisposed; if (disposed == null) { disposed = new DisposedException("Subscription has been disposed."); final StackTraceElement[] stackTrace = disposed.getStackTrace(); if (stackTrace.length > 0) { disposed.setStackTrace(new StackTraceElement[] { stackTrace[0] }); } sharedDisposed = disposed; } delegate().onThrowable(disposed); } return State.ABORT; }
Source:
<code>public void processMessageOneByOne() { <START> receiverClient.receiveMessages().flatMap(messageReceiverWorker::processMessageOneByOne).blockLast(); <END> }</code><technical_language>If demonstrating user do async client, feels unnatural suggest approach is block. Thoughts</technical_language>

Target:
public Disposable processMessageOneByOne() { return receiverClient.receiveMessages().flatMap(messageReceiverWorker::processMessageOneByOne).subscribe(); }
Source:
<code>private void createOrResumeXidTransaction(final XidTransactionID xidTransactionID) throws Exception { final TransactionManager transactionManager = this.ejbRemoteTransactionsRepository.getTransactionManager(); final Transaction alreadyCreatedTx = this.ejbRemoteTransactionsRepository.getImportedTransaction(xidTransactionID); if (alreadyCreatedTx != null) { transactionManager.resume(alreadyCreatedTx); } else { <START> final Transaction newSubOrdinateTx = this.ejbRemoteTransactionsRepository.importTransaction(xidTransactionID, Integer.parseInt(System.getProperty("remote-tx-timeout", "31536000"))); <END> transactionManager.resume(newSubOrdinateTx); } }</code><technical_language>this propagates timeout? sets this system property? Propagate imply is else is configured in common place. passed in InterceptorFactoryContext configurable in some place. introducing new attribute in mgmt model</technical_language>

Target:
private void createOrResumeXidTransaction(final XidTransactionID xidTransactionID) throws Exception { final TransactionManager transactionManager = this.ejbRemoteTransactionsRepository.getTransactionManager(); final Transaction alreadyCreatedTx = this.ejbRemoteTransactionsRepository.getImportedTransaction(xidTransactionID); if (alreadyCreatedTx != null) { transactionManager.resume(alreadyCreatedTx); } else { final Transaction newSubOrdinateTx = this.ejbRemoteTransactionsRepository.importTransaction(xidTransactionID, Integer.getInteger("org.jboss.as.ejb3.remote-tx-timeout", 31536000)); transactionManager.resume(newSubOrdinateTx); } }
Source:
<code>public static Expression rewriteIdentifiersToSymbolReferences(Expression expression) { return ExpressionTreeRewriter.rewriteWith(new ExpressionRewriter<Void>() { @Override public Expression rewriteIdentifier(Identifier node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new SymbolReference(node.getValue()); } @Override public Expression rewriteLambdaExpression(LambdaExpression node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new LambdaExpression(node.getArguments(), treeRewriter.rewrite(node.getBody(), context)); } @Override public Expression rewriteFunctionCall(FunctionCall node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { <START> if (node.getName().equals(QualifiedName.of("$INTERNAL$DEFERRED_SYMBOL_REFERENCE"))) { <END> List<Expression> arguments = node.getArguments(); checkArgument(arguments.size() == 4, "4 arguments are expected"); checkArgument(arguments.stream().allMatch(Identifier.class::isInstance), "arguments are expected to be identifiers"); ComparisonExpressionType type = ComparisonExpressionType.valueOf(((Identifier) arguments.get(0)).getValue()); SymbolReference probeSymbol = new SymbolReference(((Identifier) arguments.get(1)).getValue()); String dfSymbol = ((Identifier) arguments.get(2)).getValue(); String sourceId = ((Identifier) arguments.get(3)).getValue(); return new DynamicFilterExpression(sourceId, type, probeSymbol, dfSymbol); } return super.rewriteFunctionCall(node, context, treeRewriter); } }, expression); }</code><technical_language>is $INTERNAL$DEFERRED_SYMBOL_REFERENCE" is needed? I rid of them? I understand is SQL syntax for DynamicFilterExpression serialized SQL: $INTERNAL$dynamicFilter(...) deserialized DynamicFilterExpression</technical_language>

Target:
public static Expression rewriteIdentifiersToSymbolReferences(Expression expression) { return ExpressionTreeRewriter.rewriteWith(new ExpressionRewriter<Void>() { @Override public Expression rewriteIdentifier(Identifier node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new SymbolReference(node.getValue()); } @Override public Expression rewriteLambdaExpression(LambdaExpression node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { return new LambdaExpression(node.getArguments(), treeRewriter.rewrite(node.getBody(), context)); } @Override public Expression rewriteFunctionCall(FunctionCall node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { if (node.getName().equals(QualifiedName.of("$INTERNAL$DYNAMIC_FILTER"))) { List<Expression> arguments = node.getArguments(); checkArgument(arguments.size() == 3, "3 arguments are expected"); checkArgument(arguments.stream().allMatch(Identifier.class::isInstance), "arguments are expected to be identifiers"); SymbolReference probeSymbol = new SymbolReference(((Identifier) arguments.get(0)).getValue()); String dfSymbol = ((Identifier) arguments.get(1)).getValue(); String sourceId = ((Identifier) arguments.get(2)).getValue(); return new DynamicFilterExpression(sourceId, probeSymbol, dfSymbol); } return super.rewriteFunctionCall(node, context, treeRewriter); } }, expression); }
Source:
<code>public RebalanceInProgressException() { <START> super("Request cannot be completed since the consumer group is rebalancing. This can happen when a group has started, " + <END> "but not finished rebalancing before the request is sent. You can try completing the rebalance " + "by calling poll() and then retry the operation"); }</code><technical_language>this extend RetriableCommitFailedException</technical_language>

Target:
public RebalanceInProgressException() { super(); }
Source:
<code>public long createClient(String name, String user, String description) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); <START> byte[] generateIdBytes = new byte[8]; <END> random.nextBytes(generateIdBytes); ByteBuffer generateIdByteBuffer = ByteBuffer.wrap(generateIdBytes); long generatedId = generateIdByteBuffer.getLong(); String rowHmac = cryptographer.computeRowHmac(CLIENTS.getName(), name, generatedId); r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setRowHmac(rowHmac); r.store(); return r.getId(); }</code><technical_language>a "give a random long" helper function</technical_language>

Target:
public long createClient(String name, String user, String description) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac(CLIENTS.getName(), name, generatedId); r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setRowHmac(rowHmac); r.store(); return r.getId(); }
Source:
<code>public VariantContextBuilder genotypes(final GenotypesContext genotypes) { this.genotypes = genotypes; <START> if ( genotypes != null ) <END> genotypes.immutable(); toValidate.add(VariantContext.Validation.GENOTYPES); return this; }</code><technical_language>a bug! Introduced lack of { }! Please add some { }s</technical_language>

Target:
public VariantContextBuilder genotypes(final GenotypesContext genotypes) { this.genotypes = genotypes; if (genotypes != null) { genotypes.immutable(); toValidate.add(VariantContext.Validation.GENOTYPES); } return this; }
Source:
<code>public void toString_URIs() throws BindingSetConversionException { final MapBindingSet originalBindingSet = new MapBindingSet(); originalBindingSet.addBinding("x", new URIImpl("http://a")); originalBindingSet.addBinding("y", new URIImpl("http://b")); originalBindingSet.addBinding("z", new URIImpl("http://c")); final VisibilityBindingSet visiSet = new VisibilityBindingSet(originalBindingSet, "A&B&C"); final VariableOrder varOrder = new VariableOrder("y", "z", "x"); final VisibilityBindingSetStringConverter converter = new VisibilityBindingSetStringConverter(); final String bindingSetString = converter.convert(visiSet, varOrder); final String expected = "http://b<<~>><LINK_0>" + "http://c<<~>><LINK_0>" + "http://a<<~>><LINK_1>" + <START> (char)1 + "A&B&C"; <END> assertEquals(expected, bindingSetString); }</code><technical_language>want store (char)1 delimiter a constant reference here</technical_language>

Target:
public void toString_URIs() throws BindingSetConversionException { final MapBindingSet originalBindingSet = new MapBindingSet(); originalBindingSet.addBinding("x", new URIImpl("http://a")); originalBindingSet.addBinding("y", new URIImpl("http://b")); originalBindingSet.addBinding("z", new URIImpl("http://c")); final VisibilityBindingSet visiSet = new VisibilityBindingSet(originalBindingSet, "A&B&C"); final VariableOrder varOrder = new VariableOrder("y", "z", "x"); final VisibilityBindingSetStringConverter converter = new VisibilityBindingSetStringConverter(); final String bindingSetString = converter.convert(visiSet, varOrder); final String expected = "http://b<<~>><LINK_0>" + "http://c<<~>><LINK_0>" + "http://a<<~>><LINK_1>" + VISIBILITY_DELIM + "A&B&C"; assertEquals(expected, bindingSetString); }
Source:
<code>public Mono<Secret> setSecret(Secret secret) { return withContext(context -> setSecretWithResponse(secret)) <START> .flatMap(FluxUtil::toMono); <END> }</code><technical_language>this be: java return setSecretWithResponse(secret).flatMap(FluxUtil::toMono);</technical_language>

Target:
public Mono<Secret> setSecret(Secret secret) { return setSecretWithResponse(secret).flatMap(FluxUtil::toMono); }
Source:
<code>public String toStringShort() { <START> return MoreObjects.toStringHelper("") <END> .add("ClientType", getStringFromOptional(mClientType)) .add("ClientHostname", mLocalHostName) .add("ServerAddress", mServerAddress) .add("ChannelId", mChannelId) .omitNullValues() .toString(); }</code><technical_language>I confused this is supposed "" this</technical_language>

Target:
public String toStringShort() { return MoreObjects.toStringHelper(this) .add("ClientType", getStringFromOptional(mClientType)) .add("ClientHostname", mLocalHostName) .add("ServerAddress", mServerAddress) .add("ChannelId", mChannelId) .omitNullValues() .toString(); }
Source:
<code>public void testAddJDBCRealmAdminOnlyMode() throws Exception { <START> ModelControllerClient client = ModelControllerClient.Factory <END> .create(new ModelControllerClientConfiguration.Builder().setHostName(CoreUtils.getDefaultHost(false)) .setPort(PORT).setConnectionTimeout(CONNECTION_TIMEOUT_IN_MS).build()); ServerReload.executeReloadAndWaitForCompletion(client, CONNECTION_TIMEOUT_IN_MS, ADMIN_ONLY, TestSuiteEnvironment.getServerAddress(), PORT, null); ModelNode operation = new ModelNode(); operation.get(OP_ADDR).setEmptyList(); operation.get(OP).set(READ_ATTRIBUTE_OPERATION); operation.get(NAME).set("running-mode"); assertEquals("ADMIN_ONLY", client.execute(operation).get("result").asString()); operation = new ModelNode(); ModelNode params = new ModelNode(); params.get("sql").set("SELECT * FROM Users WHERE username = ?"); params.get("data-source").set("ExampleDS"); operation.get(OP_ADDR).add("subsystem", "elytron").add("jdbc-realm", "MyRealm"); operation.get("principal-query").add(params); operation.get(OP).set(ADD); assertSuccess(client.execute(operation)); client.close(); }</code><technical_language>This injected with: @ArquillianResource ManagementClient managementClient; do ModelControllerClient client = managementClient.getControllerClient();</technical_language>

Target:
public void testAddJDBCRealmAdminOnlyMode() throws Exception { ModelControllerClient client = managementClient.getControllerClient(); ServerReload.executeReloadAndWaitForCompletion(client, CONNECTION_TIMEOUT_IN_MS, ADMIN_ONLY_MODE, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), null); ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), "running-mode"); assertEquals("ADMIN_ONLY", client.execute(operation).get("result").asString()); ModelNode params = new ModelNode(); params.get("sql").set("SELECT * FROM Users WHERE username = ?"); params.get("data-source").set("ExampleDS"); operation = Operations.createAddOperation(Operations.createAddress("subsystem", "elytron", "jdbc-realm", "MyRealm")); operation.get("principal-query").add(params); assertSuccess(client.execute(operation)); operation = Operations.createRemoveOperation(Operations.createAddress("subsystem", "elytron", "jdbc-realm", "MyRealm")); assertSuccess(client.execute(operation)); }
Source:
<code><START> public static KeyBuilder.RowStep builder(boolean copyBytes) { <END> return new KeyBuilder.AbstractKeyBuilder(copyBytes); }</code><technical_language>I moved this end beginning</technical_language>

Target:
public static KeyBuilder.RowStep builder(boolean copyBytes) { return new KeyBuilder.KeyBuilderImpl(copyBytes); }
Source:
<code><START> public static void trace(String option, String message, Throwable throwable) { <END> System.out.println(message); if(fgDebugTrace != null) { fgDebugTrace.trace(option, message, throwable); } }</code><technical_language>Please duplicate logic in GdbPlugin.debug() breaks printouts in lines of 100 characters. I if do this for sysout call for file well? Files read a smart pager do wrapping, while Eclipse console not. do think</technical_language>

Target:
public static void trace(String option, String message, Throwable throwable) { String systemPrintableMessage = message; while (systemPrintableMessage.length() > 100) { String partial = systemPrintableMessage.substring(0, 100); systemPrintableMessage = systemPrintableMessage.substring(100); System.out.println(partial + "\\"); } if(fgDebugTrace != null) { fgDebugTrace.trace(option, message, throwable); } }
Source:
<code>private List<SubscriptionBundle> filterBundles(final List<SubscriptionBundle> subscriptionBundlesForAccountId, final List<String> bundlesFilter) { List<SubscriptionBundle> result = new ArrayList<SubscriptionBundle>(); for (SubscriptionBundle subscription : subscriptionBundlesForAccountId) { <START> if (bundlesFilter.contains(subscription.getId().toString())) { <END> result.add(subscription); } } return result; }</code><technical_language>Variable name change bundle subscriptionBundle this is a subscription object</technical_language>

Target:
private List<SubscriptionBundle> filterBundles(final List<SubscriptionBundle> subscriptionBundlesForAccountId, final List<String> bundlesFilter) { List<SubscriptionBundle> result = new ArrayList<SubscriptionBundle>(); for (SubscriptionBundle subscriptionBundle : subscriptionBundlesForAccountId) { if (bundlesFilter.contains(subscriptionBundle.getId().toString())) { result.add(subscriptionBundle); } } return result; }
Source:
<code><START> public void setContent(byte[] newContent) { <END> ArrayList<CommentInfo> newComments = new CommentExtractor().extractComments(documentWithComments, gerritComments, new Document(new String(newContent))); for (CommentInfo newComment : newComments) { CreateDraftCommand publishDraft = gerrit.createDraftComments(change_id, fileInfo.getContainingRevisionInfo().getId()); publishDraft.setCommentInfo(newComment); newComment.setPath(fileName); CommentInfo result = null; try { result = publishDraft.call(); } catch (EGerritException e) { } catch (ClientProtocolException e) { } } }</code><technical_language>please add some docu in header for a public method</technical_language>

Target:
public void setContent(byte[] newContent) { ArrayList<CommentInfo> newComments = new CommentExtractor().extractComments(documentWithComments, gerritComments, new Document(new String(newContent))); for (CommentInfo newComment : newComments) { CreateDraftCommand publishDraft = gerrit.createDraftComments(change_id, fileInfo.getContainingRevisionInfo().getId()); publishDraft.setCommentInfo(newComment); newComment.setPath(fileName); try { publishDraft.call(); } catch (EGerritException e) { throw new RuntimeException(CompareItem.class.getName(), e); } catch (ClientProtocolException e) { throw new RuntimeException(CompareItem.class.getName(), e); } } }
Source:
<code>public String getName() { <START> return Constant.messages.getString(MESSAGE_PREFIX + "name"); <END> }</code><technical_language>Call getString(String)</technical_language>

Target:
public String getName() { return getString("name"); }
Source:
<code>protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof PingWebSocketFrame) { frame.content().retain(); ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content())); if (!ctx.channel().config().isAutoRead()) { ctx.read(); <START> } <END> return; } if (frame instanceof PongWebSocketFrame && dropPongFrames) { if (!ctx.channel().config().isAutoRead()) { ctx.read(); } return; } out.add(frame.retain()); }</code><technical_language>factor out this a method call method: private static void readIfNeeded(ChannelHandlerContext ctx) { if (!ctx.channel.config().isAutoRead()) { ctx.read(); } }</technical_language>

Target:
protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof PingWebSocketFrame) { frame.content().retain(); ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content())); readIfNeeded(ctx); return; } if (frame instanceof PongWebSocketFrame && dropPongFrames) { readIfNeeded(ctx); return; } out.add(frame.retain()); }