auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>ImmutableDomainWildcardMapping(V defaultValue, Map<String, V> map) { this.defaultValue = defaultValue; <START> this.map = Collections.unmodifiableMap(map); <END> }</code><technical_language>DomainWildcardMappingBuilder::build is alredy creating a fresh new map owned ImmutableDomainWildcardMapping: if copy of DomainWildcardMappingBuilder::map happen new ImmutableDomainWildcardMapping, save unmodifiableMap pointer chasing introduced</technical_language>

Target:
ImmutableDomainWildcardMapping(V defaultValue, Map<String, V> map) { this.defaultValue = defaultValue; this.map = new LinkedHashMap<String, V>(map); }
Source:
<code>public List<ConfigurationFlag> getConfigurationFlag() { <START> return configurationFlag; <END> }</code><technical_language>this.configurationFlag ("this." added save actions?)</technical_language>

Target:
public List<ConfigurationFlag> getConfigurationFlag() { return Collections.unmodifiableList(this.configurationFlag); }
Source:
<code>private Guid getSnapshotId(Snapshots snapshots) { return <START> (snapshots.getSnapshots() != null && <END> !snapshots.getSnapshots().isEmpty()) ? asGuid(snapshots.getSnapshots().get(0).getId()) : Guid.Empty; }</code><technical_language>if snapshots.getSnapshots() == null fail NPE in validateSnapshotExistence, no</technical_language>

Target:
private Guid getSnapshotId(Snapshots snapshots) { return asGuid(snapshots.getSnapshots().get(0).getId()); }
Source:
<code><START> public Graphics2D prepareImageRenderer(MapTransform mt, BufferedImage img, ProgressMonitor pm) { <END> Graphics2D g2 = img.createGraphics(); if (backgroundColor != null) { g2.setBackground(backgroundColor); g2.clearRect(0, 0, width, height); } ImageRenderer renderer = new ImageRenderer(); renderer.draw(mt, g2, width, height, rootLayer, pm); return g2; }</code><technical_language>this function is public ? of this class</technical_language>

Target:
private Graphics2D prepareImageRenderer(MapTransform mt, BufferedImage img, ProgressMonitor pm) { Graphics2D g2 = img.createGraphics(); if (backgroundColor != null) { g2.setBackground(backgroundColor); g2.clearRect(0, 0, width, height); } ImageRenderer renderer = new ImageRenderer(); renderer.draw(mt, g2, width, height, rootLayer, pm); return g2; }
Source:
<code>public void testObisCodeValues2() { final AdhocMapper mapper = new AdhocMapper(); final com.alliander.osgp.domain.core.valueobjects.smartmetering.ObisCodeValues obisCodeValues1 = new com.alliander.osgp.domain.core.valueobjects.smartmetering.ObisCodeValues((byte)1, (byte)2, (byte)3, (byte)-22, (byte)5, (byte)-1); final ObisCodeValues obisCodeValues2 = mapper.map( obisCodeValues1, ObisCodeValues.class); Assert.assertEquals((short) 1, obisCodeValues2.getA()); Assert.assertEquals((short) 2, obisCodeValues2.getB()); Assert.assertEquals((short) 3, obisCodeValues2.getC()); <START> Assert.assertEquals((short) -22, obisCodeValues2.getD()); <END> Assert.assertEquals((short) 5, obisCodeValues2.getE()); Assert.assertEquals((short) -1, obisCodeValues2.getF()); }</code><technical_language>be: Assert.assertEquals((short) 234, obisCodeValues2.getD());</technical_language>

Target:
public void testObisCodeValues2() { final AdhocMapper mapper = new AdhocMapper(); final com.alliander.osgp.domain.core.valueobjects.smartmetering.ObisCodeValues obisCodeValues1 = new com.alliander.osgp.domain.core.valueobjects.smartmetering.ObisCodeValues((byte)1, (byte)2, (byte)3, (byte)-22, (byte)5, (byte)-1); final ObisCodeValues obisCodeValues2 = mapper.map( obisCodeValues1, ObisCodeValues.class); Assert.assertEquals((short) 1, obisCodeValues2.getA()); Assert.assertEquals((short) 2, obisCodeValues2.getB()); Assert.assertEquals((short) 3, obisCodeValues2.getC()); Assert.assertEquals((short) 234, obisCodeValues2.getD()); Assert.assertEquals((short) 5, obisCodeValues2.getE()); Assert.assertEquals((short) 255, obisCodeValues2.getF()); }
Source:
<code>private int calculateLifeTime() { <START> int lifeTime = ThreadLocalRandom.current().nextInt(5, 46); <END> int level = getEnchantmentLevel(Enchantment.LURE); lifeTime -= level * 5; lifeTime = Math.max(lifeTime, 0); lifeTime *= 20; return lifeTime; }</code><technical_language>Put values in constants</technical_language>

Target:
private int calculateLifeTime() { int lifeTime = ThreadLocalRandom.current().nextInt(MINIMUM_BASE_WAIT, MAXIMUM_WAIT + 1); int level = getEnchantmentLevel(Enchantment.LURE); lifeTime -= level * SECONDS_SAVED_PER_LURE_LEVEL; lifeTime = Math.max(lifeTime, 0); lifeTime *= 20; return lifeTime; }
Source:
<code>static <C extends ProtocolConfiguration, B extends AbstractProtocolConfigurationBuilder<C>> B addProtocolProperties(OperationContext context, ModelNode protocol, B builder) throws OperationFailedException { if (protocol.hasDefined(ProtocolResourceDefinition.PROPERTIES.getName())) { for (Property property : protocol.get(ProtocolResourceDefinition.PROPERTIES.getName()).asPropertyList()) { <START> builder.addProperty(property.getName(), property.getValue().asString()); <END> } } return builder; }</code><technical_language>This needs resolve expressions</technical_language>

Target:
static <C extends ProtocolConfiguration, B extends AbstractProtocolConfigurationBuilder<C>> B addProtocolProperties(OperationContext context, ModelNode protocol, B builder) throws OperationFailedException { if (protocol.hasDefined(ProtocolResourceDefinition.PROPERTIES.getName())) { for (Property property : ProtocolResourceDefinition.PROPERTIES.resolveModelAttribute(context, protocol).asPropertyList()) { builder.addProperty(property.getName(), property.getValue().asString()); } } return builder; }
Source:
<code>private void readFile(Path file, int nRows, boolean verifyChecksums, Blackhole blackhole) throws IOException { <START> ParquetReader<Group> reader = ParquetReader.builder(new GroupReadSupport(), file) <END> .withConf(configuration) .usePageChecksumVerification(verifyChecksums) .build(); for (int i = 0; i < nRows; i++) { Group group = reader.read(); blackhole.consume(group.getLong("long_field", 0)); blackhole.consume(group.getBinary("binary_field", 0)); Group subgroup = group.getGroup("group", 0); blackhole.consume(subgroup.getInteger("int_field", 0)); blackhole.consume(subgroup.getInteger("int_field", 1)); blackhole.consume(subgroup.getInteger("int_field", 2)); blackhole.consume(subgroup.getInteger("int_field", 3)); } reader.close(); }</code><technical_language>wrap a try-with-resource this</technical_language>

Target:
private void readFile(Path file, int nRows, boolean verifyChecksums, Blackhole blackhole) throws IOException { try (ParquetReader<Group> reader = ParquetReader.builder(new GroupReadSupport(), file) .withConf(configuration) .usePageChecksumVerification(verifyChecksums) .build()) { for (int i = 0; i < nRows; i++) { Group group = reader.read(); blackhole.consume(group.getLong("long_field", 0)); blackhole.consume(group.getBinary("binary_field", 0)); Group subgroup = group.getGroup("group", 0); blackhole.consume(subgroup.getInteger("int_field", 0)); blackhole.consume(subgroup.getInteger("int_field", 1)); blackhole.consume(subgroup.getInteger("int_field", 2)); blackhole.consume(subgroup.getInteger("int_field", 3)); } } }
Source:
<code>public DoubleSumAggregatorFactory( @JsonProperty("name") String name, @JsonProperty("fieldName") final String fieldName ) { Preconditions.checkNotNull(name, "Must have a valid, nonl null aggregator name"); <START> Preconditions.checkNotNull(fieldName, "Must have a valid, non null fieldName"); <END> this.name = name; this.fieldName = fieldName; }</code><technical_language>I if adding a bit more information messages nicer. Like, "doubleSum" values of name/fieldName in case is in of identify object issue</technical_language>

Target:
public DoubleSumAggregatorFactory( @JsonProperty("name") String name, @JsonProperty("fieldName") final String fieldName ) { Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); this.name = name; this.fieldName = fieldName; }
Source:
<code>public void cipherCanEncode() { String plainText = "aaaaaaaaaa"; String cipherText = cipherWithDefaultKey.getKey().substring(0, 10); assertEquals(cipherText, cipherWithDefaultKey.encode("aaaaaaaaaa")); <START> assertEquals(cipherText, cipherWithDefaultKey.encode(plainText)); <END> }</code><technical_language>need assert equals statements</technical_language>

Target:
public void cipherCanEncode() { String plainText = "aaaaaaaaaa"; String cipherText = cipherWithDefaultKey.getKey().substring(0, 10); assertEquals(cipherText, cipherWithDefaultKey.encode(plainText)); }
Source:
<code>public boolean isPartVisible(MPart part) { if (isInActivePerspective(part)) { MUIElement element = part; MElementContainer<?> parent = part.getParent(); if (parent == null) { element = part.getCurSharedRef(); if (element == null) { return false; } parent = element.getParent(); if (parent == null) { return false; } } if (parent instanceof MPartStack) { <START> boolean isSelected = parent.getSelectedElement() == element; <END> if (!isSelected) { return false; } if (isMinimized(parent) || isMinimized(part)) { return false; } return true; } if (!element.isVisible()) { return false; } if (isMinimized(parent) || isMinimized(part)) { return false; } return true; } return false; }</code><technical_language>This code right. 1. I MPartStacks get tagged MINIMIZED MINIMIZED_BY_ZOOM, checking isMinimized() for else is a no-op. I guess hurt check though. 2. values interested in checking MPlaceholders, I need check isMinimized(element) isMinimized(part). 2. MParts/MPlaceholders in a minimized MPartStack continue visible=true. MParts/MPlaceholders in MPartSashContainer visible=false. I expected like: > if(parent instanceof MPartStack && ((MPartStack)parent).getSelectedElement() != element) { > return false; > } > if(isMinimized(parent) || isMinimized(element)) { > return false; > } > return element.isVisible(); (which passes tests)</technical_language>

Target:
public boolean isPartVisible(MPart part) { if (isInActivePerspective(part)) { MUIElement element = part; MElementContainer<?> parent = part.getParent(); if (parent == null) { element = part.getCurSharedRef(); if (element == null) { return false; } parent = element.getParent(); if (parent == null) { return false; } } if (parent instanceof MPartStack && parent.getSelectedElement() != element) { return false; } if (!element.isVisible()) { return false; } if (isMinimized(parent) || isMinimized(element)) { return false; } return true; } return false; }
Source:
<code>public void testCaseWhenElse() throws DatabaseEngineException { test5Columns(); engine.persist("TEST", entry().set("COL1", 1).set("COL5", "teste") .build()); engine.persist("TEST", entry().set("COL1", 2).set("COL5", "TESTE") .build()); engine.persist("TEST", entry().set("COL1", 3).set("COL5", "TeStE") .build()); engine.persist("TEST", entry().set("COL1", 4).set("COL5", "teste") .build()); List<Map<String, ResultColumn>> query = engine.query( select(all(), caseElse(eq(column("COL5"), k("teste")), k("LOL"), k("ROFL")).alias("case")) .from(table("TEST")) ); assertEquals("COL5 must be LOL", "LOL", query.get(0).get("case").toString()); assertEquals("COL5 must be ROFL", "ROFL", query.get(1).get("case").toString()); assertEquals("COL5 must be ROFL", "ROFL", query.get(2).get("case").toString()); assertEquals("COL5 must be LOL", "LOL", query.get(3).get("case").toString()); <START> } <END></code><technical_language>Missing test more 1 case</technical_language>

Target:
public void testCaseWhenElse() throws DatabaseEngineException { test5Columns(); engine.persist("TEST", entry().set("COL1", 1).set("COL5", "teste") .build()); engine.persist("TEST", entry().set("COL1", 2).set("COL5", "xpto") .build()); engine.persist("TEST", entry().set("COL1", 3).set("COL5", "xpto") .build()); engine.persist("TEST", entry().set("COL1", 4).set("COL5", "teste") .build()); List<Map<String, ResultColumn>> result = engine.query( select(caseWhen().when(eq(column("COL5"), k("teste")), k("LOL")) .otherwise(k("ROFL")).alias("case")) .from(table("TEST")) ); assertEquals("COL5 must be LOL", "LOL", result.get(0).get("case").toString()); assertEquals("COL5 must be ROFL", "ROFL", result.get(1).get("case").toString()); assertEquals("COL5 must be ROFL", "ROFL", result.get(2).get("case").toString()); assertEquals("COL5 must be LOL", "LOL", result.get(3).get("case").toString()); }
Source:
<code>public boolean processNextEvent() { if (queue.isEmpty() || status.get() == Status.RUNNING) { return false; } if (status.compareAndSet(Status.READY, Status.RUNNING)) { if (queue.isEmpty()) { status.set(Status.READY); return false; } final Tuple<MistEvent, Direction> event; synchronized (sharedLock) { event = queue.poll(); } process(event); status.set(Status.READY); <START> if (operatorChainManager != null && !queue.isEmpty()) { <END> operatorChainManager.insert(this); } return true; } else { return false; } }</code><technical_language>sharedLock in in addNextEvent</technical_language>

Target:
public boolean processNextEvent() { if (queue.isEmpty() || status.get() == Status.RUNNING) { return false; } if (status.compareAndSet(Status.READY, Status.RUNNING)) { if (queue.isEmpty()) { status.set(Status.READY); return false; } final Tuple<MistEvent, Direction> event; synchronized (this) { event = queue.poll(); } process(event); status.set(Status.READY); if (operatorChainManager != null && !queue.isEmpty()) { operatorChainManager.insert(this); } return true; } else { return false; } }
Source:
<code>protected boolean executeAnalysis(@Nullable final IProgressMonitor monitor) { IProgressMonitor mon = (monitor == null ? new NullProgressMonitor() : monitor); final ITmfStateProvider provider = createStateProvider(); String id = getId(); try { StateSystemBackendType backend = getBackendType(); String directory; File htFile; ITmfTrace trace = getTrace(); if (trace == null) { return false; } switch (backend) { case FULL: directory = TmfTraceManager.getSupplementaryFileDir(trace); htFile = new File(directory + getSsFileName()); createFullHistory(id, provider, htFile); break; case PARTIAL: directory = TmfTraceManager.getSupplementaryFileDir(trace); htFile = new File(directory + getSsFileName()); createPartialHistory(id, provider, htFile); break; case INMEM: createInMemoryHistory(id, provider); break; case NULL: createNullHistory(id, provider); break; default: break; } <START> } catch (TmfTraceException e) { <END> return false; } return !mon.isCanceled(); }</code><technical_language>countDown</technical_language>

Target:
protected boolean executeAnalysis(@Nullable final IProgressMonitor monitor) { IProgressMonitor mon = (monitor == null ? new NullProgressMonitor() : monitor); final ITmfStateProvider provider = createStateProvider(); String id = getId(); try { StateSystemBackendType backend = getBackendType(); String directory; File htFile; ITmfTrace trace = getTrace(); if (trace == null) { fInitialized.countDown(); return false; } switch (backend) { case FULL: directory = TmfTraceManager.getSupplementaryFileDir(trace); htFile = new File(directory + getSsFileName()); createFullHistory(id, provider, htFile); break; case PARTIAL: directory = TmfTraceManager.getSupplementaryFileDir(trace); htFile = new File(directory + getSsFileName()); createPartialHistory(id, provider, htFile); break; case INMEM: createInMemoryHistory(id, provider); break; case NULL: createNullHistory(id, provider); break; default: break; } } catch (TmfTraceException e) { fInitialized.countDown(); return false; } return !mon.isCanceled(); }
Source:
<code>protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final boolean debug = this.logger.isDebugEnabled(); try { UsernamePasswordAuthenticationToken authRequest = authenticationConverter.convert(request); if (authRequest == null) { chain.doFilter(request, response); return; } String username = authRequest.getName(); if (debug) { this.logger .debug("Basic Authentication Authorization header found for user '" + username + "'"); } if (authenticationIsRequired(username)) { Authentication authResult = this.authenticationManager .authenticate(authRequest); if (debug) { this.logger.debug("Authentication success: " + authResult); } SecurityContextHolder.getContext().setAuthentication(authResult); this.rememberMeServices.loginSuccess(request, response, authResult); onSuccessfulAuthentication(request, response, authResult); } } catch (AuthenticationException failed) { SecurityContextHolder.clearContext(); if (debug) { <START> this.logger.debug("Authentication request for failed: " + failed, failed); <END> } this.rememberMeServices.loginFail(request, response); onUnsuccessfulAuthentication(request, response, failed); if (this.ignoreFailure) { chain.doFilter(request, response); } else { this.authenticationEntryPoint.commence(request, response, failed); } return; } chain.doFilter(request, response); }</code><technical_language>Please change debug message BearerTokenAuthenticationFilter <LINK_0></technical_language>

Target:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final boolean debug = this.logger.isDebugEnabled(); try { UsernamePasswordAuthenticationToken authRequest = authenticationConverter.convert(request); if (authRequest == null) { chain.doFilter(request, response); return; } String username = authRequest.getName(); if (debug) { this.logger .debug("Basic Authentication Authorization header found for user '" + username + "'"); } if (authenticationIsRequired(username)) { Authentication authResult = this.authenticationManager .authenticate(authRequest); if (debug) { this.logger.debug("Authentication success: " + authResult); } SecurityContextHolder.getContext().setAuthentication(authResult); this.rememberMeServices.loginSuccess(request, response, authResult); onSuccessfulAuthentication(request, response, authResult); } } catch (AuthenticationException failed) { SecurityContextHolder.clearContext(); if (debug) { this.logger.debug("Authentication request for failed!", failed); } this.rememberMeServices.loginFail(request, response); onUnsuccessfulAuthentication(request, response, failed); if (this.ignoreFailure) { chain.doFilter(request, response); } else { this.authenticationEntryPoint.commence(request, response, failed); } return; } chain.doFilter(request, response); }
Source:
<code>private FilterExpression parseQuotedContent(QualifierType type, Token token) { String keywords = token.getValue(); <START> keywords = keywords.substring(1, keywords.length() - 1); <END> return new Qualifier(type, keywords); }</code><technical_language>Instead of this (which remove correct characters), Utility.stripQuotes trim</technical_language>

Target:
private FilterExpression parseQuotedContent(QualifierType type, Token token) { String keywords = token.getValue(); return new Qualifier(type, Utility.stripQuotes(keywords)); }
Source:
<code>public DefaultDevToolsFactory(final Config config) { _chromePath = config.getString("path"); _chromeArgs = ImmutableMap.copyOf(config.getObject("args").unwrapped()); <START> _executor = createExecutorService(config.getConfig("executor")); <END> _service = Suppliers.memoize(this::createService); }</code><technical_language>If executor block exists, this return null defaults I NPE</technical_language>

Target:
public DefaultDevToolsFactory(final Config config) { _chromePath = config.getString("path"); _chromeArgs = ImmutableMap.copyOf(config.getObject("args").unwrapped()); _executor = createExecutorService(config.hasPath("executor") ? config.getConfig("executor") : ConfigFactory.empty()); _service = Suppliers.memoize(this::createService); }
Source:
<code>Object saveLabel(@PathVariable("pid") String pid, @RequestParam("label") String label) throws IngestException { if (label != null && label.trim().length() > 0) { try { PremisEventLogger logger = new PremisEventLogger(pid); PID pidObject = new PID(pid); this.client.modifyObject(pidObject, label, null, null, null); <START> Element event = logger.logEvent(PremisEventLogger.Type.NORMALIZATION, "Object renamed to " + label, pidObject); <END> PremisEventLogger.addDetailedOutcome(event, "success", "Message: Object renamed successfully", null); this.client.writePremisEventsToFedoraObject(logger, pidObject); } catch (FedoraException e) { throw new IngestException("Could not update label for " + pid, e); } } else { Map <String, String> response = new HashMap<>(); response.put("message", "error"); return response ; } Map <String, String> response = new HashMap<>(); response.put("message", "success"); return response; }</code><technical_language>MIGRATION event type for move operations, match definition of type of event, switch this for consistency</technical_language>

Target:
Object saveLabel(@PathVariable("pid") String pid, @RequestParam("label") String label) throws IngestException { if (label != null && label.trim().length() > 0) { try { PremisEventLogger logger = new PremisEventLogger(pid); PID pidObject = new PID(pid); this.client.modifyObject(pidObject, label, null, null, null); Element event = logger.logEvent(PremisEventLogger.Type.MIGRATION, "Object renamed to " + label, pidObject); PremisEventLogger.addDetailedOutcome(event, "success", "Object renamed successfully", null); this.client.writePremisEventsToFedoraObject(logger, pidObject); } catch (FedoraException e) { throw new IngestException("Could not update label for " + pid, e); } } else { Map <String, String> response = new HashMap<>(); response.put("message", "error"); return response ; } Map <String, String> response = new HashMap<>(); response.put("message", "success"); return response; }
Source:
<code>public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = null; try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: exception = new IllegalArgumentException(message); break; case 404: if (command.getCurrentRequest().getMethod().equals("DELETE")) { if (command.getCurrentRequest().getEndpoint().getPath().startsWith("/" + EtcdApiMetadata.API_VERSION + "/keys") && message.contains("Key not found")) { exception = new ResourceNotFoundException("Could not find key to delete: message=" + message, new HttpResponseException(command, response, message)); } } else if (command.getCurrentRequest().getMethod().equals("GET")) { if (command.getCurrentRequest().getEndpoint().getPath().startsWith("/" + EtcdApiMetadata.API_VERSION + "/keys") && message.contains("Key not found")) { exception = new ResourceNotFoundException("Could not find key: message=" + message, new HttpResponseException(command, response, message)); <START> } <END> } break; case 409: exception = new ResourceAlreadyExistsException(message); break; default: exception = new HttpResponseException(message, command, response); break; } } catch (Exception e) { exception = new HttpResponseException(command, response, e); } finally { if (exception == null) { exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); } closeQuietly(response.getPayload()); command.setException(exception); } }</code><technical_language>This inconsistent. methods configured a fallback for find key string. treated in fallback this message in error handler? And... messages describe error</technical_language>

Target:
public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = null; try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: exception = new IllegalArgumentException(message); break; case 409: exception = new ResourceAlreadyExistsException(message); break; default: exception = new HttpResponseException(message, command, response); break; } } catch (Exception e) { exception = new HttpResponseException(command, response, e); } finally { if (exception == null) { exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); } closeQuietly(response.getPayload()); command.setException(exception); } }
Source:
<code>protected Serializable copyHierRecursive(IdWithTypes source, Serializable parentId, String name, Serializable overwriteId, boolean resetVersion, Map<Serializable, Serializable> idMap, <START> Map<Serializable, IdWithTypes> idToTypes, boolean excludeSpecialChildren) throws SQLException { <END> idToTypes.put(source.id, source); Serializable newId; if (overwriteId == null) { newId = copyHier(source.id, parentId, name, resetVersion, idMap); } else { newId = overwriteId; idMap.put(source.id, newId); } boolean onlyComplex = parentId == null; for (IdWithTypes child : getChildrenIdsWithTypes(source.id, onlyComplex, excludeSpecialChildren)) { copyHierRecursive(child, newId, null, null, resetVersion, idMap, idToTypes, true); } return newId; }</code><technical_language>This part of patch in VCS-specific commit</technical_language>

Target:
protected Serializable copyHierRecursive(IdWithTypes source, Serializable parentId, String name, Serializable overwriteId, boolean resetVersion, Map<Serializable, Serializable> idMap, Map<Serializable, IdWithTypes> idToTypes, boolean excludeSpecialChildren) throws SQLException { idToTypes.put(source.id, source); Serializable newId; if (overwriteId == null) { newId = copyHier(source.id, parentId, name, resetVersion, idMap); } else { newId = overwriteId; idMap.put(source.id, newId); } boolean excludeRegularChildren = parentId == null; for (IdWithTypes child : getChildrenIdsWithTypes(source.id, excludeSpecialChildren, excludeRegularChildren)) { copyHierRecursive(child, newId, null, null, resetVersion, idMap, idToTypes, excludeSpecialChildren); } return newId; }
Source:
<code>public void should_fail_if_actual_is_null() { <START> assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> maps.assertAnySatisfy(someInfo(), null, (team, player) -> { <END> })) .withMessage(actualIsNull()); }</code><technical_language>expectAssertionError static import AssertionsUtil.assertThatAssertionErrorIsThrownBywhich is a shortcut assertThatExceptionOfType(AssertionError.class).isThrownBy</technical_language>

Target:
public void should_fail_if_actual_is_null() { AssertionError error = expectAssertionError(() -> maps.assertAnySatisfy(someInfo(), null, (team, player) -> { })); assertThat(error).hasMessage(actualIsNull()); }
Source:
<code><START> public List<CitationCollectionOrder> getNestedCollectionAsList(String citationCollectionId){ <END> return null; }</code><technical_language>null implementation</technical_language>

Target:
public List<CitationCollectionOrder> getNestedCollectionAsList(String citationCollectionId){ return (List<CitationCollectionOrder>) m_citationCollections; }
Source:
<code>public void notifyOfConnection( int hostId, SocketChannel socket, InetSocketAddress listeningAddress) throws Exception { m_networkLog.info("Host " + getHostId() + " receives a new connection from host " + hostId); prepSocketChannel(socket); ForeignHost fhost = new ForeignHost(this, hostId, socket, Integer.MAX_VALUE, listeningAddress, new PicoNetwork(socket, true)); putForeignHost(hostId, fhost); fhost.enableRead(VERBOTEN_THREADS); boolean ready = true; for (int peer : m_peers) { <START> ready = ready && m_foreignHosts.get(peer).size() == (m_secondaryConnections + 1); <END> } if (ready) { m_hasAllSecondaryConnectionCreated = true; } }</code><technical_language>break out loop earlier, soon ready is false</technical_language>

Target:
public void notifyOfConnection( int hostId, SocketChannel socket, InetSocketAddress listeningAddress) throws Exception { networkLog.info("Host " + getHostId() + " receives a new connection from host " + hostId); prepSocketChannel(socket); ForeignHost fhost = new ForeignHost(this, hostId, socket, Integer.MAX_VALUE, listeningAddress, new PicoNetwork(socket, true)); putForeignHost(hostId, fhost); fhost.enableRead(VERBOTEN_THREADS); for (int hId : m_peers) { if (m_foreignHosts.get(hId).size() != (m_secondaryConnections + 1)) { return; } } m_hasAllSecondaryConnectionCreated = true; }
Source:
<code>CompletableFuture<AggregatedHttpResponse> sendRequest() { final HttpResponse response; try (SafeCloseable ignored = Clients.withContextCustomizer(ctx -> ctx.attr(NAME).set(name))) { response = httpClient.execute(request); } CompletableFuture<AggregatedHttpResponse> responseFuture = RequestContext.mapCurrent( ctx -> response.aggregateWithPooledObjects(ctx.eventLoop(), ctx.alloc()), response::aggregate); responseFuture = responseFuture.exceptionally(t -> { if (t instanceof UnprocessedRequestException) { Throwable cause = t.getCause(); Exceptions.clearTrace(cause); <START> throw new RejectedExecutionException("Could not process request.", cause); <END> } else { Exceptions.throwUnsafely(t); } return null; }); this.responseFuture = responseFuture; return responseFuture; }</code><technical_language>nice message in exception this show health check potentially, shows direct message iirc. IOTW I "Could process request." is more telling cause.getMessage()</technical_language>

Target:
CompletableFuture<AggregatedHttpResponse> sendRequest() { final HttpResponse response; try (SafeCloseable ignored = Clients.withContextCustomizer(ctx -> ctx.attr(NAME).set(name))) { response = httpClient.execute(request); } CompletableFuture<AggregatedHttpResponse> responseFuture = RequestContext.mapCurrent( ctx -> response.aggregateWithPooledObjects(ctx.eventLoop(), ctx.alloc()), response::aggregate); responseFuture = responseFuture.exceptionally(t -> { if (t instanceof UnprocessedRequestException) { Throwable cause = t.getCause(); Exceptions.clearTrace(cause); throw new RejectedExecutionException("Rejected execution: " + cause.getMessage(), cause); } else { Exceptions.throwUnsafely(t); } return null; }); this.responseFuture = responseFuture; return responseFuture; }
Source:
<code>public void added(ModuleType moduleType) { <START> Set<String> notInitailizedRules = new HashSet<String>(20); <END> String moduleTypeName = moduleType.getUID(); Set<String> rules = null; synchronized (this) { Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { rules = new HashSet<String>(); rules.addAll(rulesPerModule); } } if (rules != null) { for (String rUID : rules) { RuleStatus ruleStatus = getRuleStatus(rUID); if (ruleStatus == RuleStatus.NOT_INITIALIZED) { notInitailizedRules.add(rUID); } } } if (notInitailizedRules != null) { for (String rUID : notInitailizedRules) { scheduleRuleInitialization(rUID); } } }</code><technical_language>notInitailizedRules set is needed</technical_language>

Target:
public void added(ModuleType moduleType) { String moduleTypeName = moduleType.getUID(); Set<String> rules = null; synchronized (this) { Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { rules = new HashSet<String>(); rules.addAll(rulesPerModule); } } if (rules != null) { for (String rUID : rules) { RuleStatus ruleStatus = getRuleStatus(rUID); if (ruleStatus == RuleStatus.NOT_INITIALIZED) { scheduleRuleInitialization(rUID); } } } }
Source:
<code>public static void register(final DataProviderRegistrator registrator) { registrator .asImmutable(BlockState.class) .create(Keys.DIRECTION) .get(h -> DirectionUtils.getFor(h.get(AbstractFurnaceBlock.FACING))) .set((h, v) -> DirectionUtils.set(h, v, AbstractFurnaceBlock.FACING)) <START> .supports(AbstractFurnaceBlock.class::isInstance) <END> .create(Keys.IS_LIT) .get(h -> h.get(AbstractFurnaceBlock.LIT)) .set((h, v) -> h.with(AbstractFurnaceBlock.LIT, v)) .supports(AbstractFurnaceBlock.class::isInstance); }</code><technical_language>Is this calling is instance BlockState BlockState.getBlock</technical_language>

Target:
public static void register(final DataProviderRegistrator registrator) { registrator .asImmutable(BlockState.class) .create(Keys.DIRECTION) .get(h -> DirectionUtils.getFor(h.get(AbstractFurnaceBlock.FACING))) .set((h, v) -> DirectionUtils.set(h, v, AbstractFurnaceBlock.FACING)) .supports(h -> h.getBlock() instanceof AbstractFurnaceBlock) .create(Keys.IS_LIT) .get(h -> h.get(AbstractFurnaceBlock.LIT)) .set((h, v) -> h.with(AbstractFurnaceBlock.LIT, v)) .supports(h -> h.getBlock() instanceof AbstractFurnaceBlock); }
Source:
<code>protected String getMarkerMessage() throws CoreException { IMarker marker = this.getMarker(); int bp_line = 0; int bp_request_line = 0; String bp_file = null; String bp_reqest_file = null; if (marker != null) { bp_line = marker.getAttribute(IMarker.LINE_NUMBER, -1); bp_request_line = marker.getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1); bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String)null); bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String)null); } if (bp_line != bp_request_line || (bp_file == null && bp_reqest_file != null) || (bp_file != null && !bp_file.equals(bp_reqest_file)) ) { StringBuffer label = new StringBuffer(); if (bp_file != null && !bp_file.equals(bp_reqest_file)) { IPath path = new Path(bp_reqest_file); if (path.isValidPath(bp_reqest_file)) { label.append(path.lastSegment()); } label.append(' '); } <START> label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), (Object[])new String[]{ Integer.toString(bp_request_line) })); END> return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.1" ), (Object[])new String[] { label.toString(), CDebugUtils.getBreakpointText( this, false ) } ); } else { return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); } }</code><technical_language>I understand this part. appends "Line breakpoint:..." messages together. For i18n purposes label text formatted a single message format. I.e. label.append(... right left languages out of luck</technical_language>

Target:
protected String getMarkerMessage() throws CoreException { return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); }
Source:
<code>private void checkIfEmxEntityType(EntityType entityType) { String entityName = entityType.getId(); <START> String packageName = entityType.getPackage() != null ? entityType.getPackage().getId() : ""; <END> if (!(packageName.isEmpty() || entityName.startsWith(packageName))) { throw new InvalidEntityIdentifierException(entityName); } }</code><technical_language>suggestion String packageName = entityType.getPackage() != null ? entityType.getPackage().getId() : null;</technical_language>

Target:
private void checkIfEmxEntityType(EntityType entityType) { String entityTypeId = entityType.getId(); String packageName = entityType.getPackage() != null ? entityType.getPackage().getId() : null; if (!(Strings.isNullOrEmpty(packageName) || entityTypeId.startsWith(packageName))) { throw new InvalidEmxIdentifierException(entityTypeId); } }
Source:
<code>public void validateRemoveTagsWhenExists() { List<ResourceTag> resourceTags = Arrays.asList(new ResourceTagVO("test", "test", 1l, 2l, 2l, ResourceTag.ResourceObjectType.UserVm, "", "test")); <START> Map<String, String> tags = new HashMap<>(); <END> List<String> resourceIds = Arrays.asList("123"); Mockito.when(taggedResourceManagerMock.getUuid("123", ResourceTag.ResourceObjectType.UserVm)).thenReturn("123"); Mockito.when(taggedResourceManagerMock.deleteTags(resourceIds, ResourceTag.ResourceObjectType.UserVm, tags)).thenReturn(true); Mockito.<List<? extends ResourceTag>>when(taggedResourceManagerMock.listByResourceTypeAndId(ResourceTag.ResourceObjectType.UserVm, 0)).thenReturn(resourceTags); Mockito.when(userVmVoMock.getUuid()).thenReturn("123"); Mockito.when(userVmDao.findById(Mockito.eq(vmId))).thenReturn(userVmVoMock); userVmManagerImpl.removeTagsFromVm(1l); }</code><technical_language>test cases assert. do check if method is want do</technical_language>

Target:
public void validateRemoveTagsWhenExists() { List<ResourceTag> resourceTags = Arrays.asList(new ResourceTagVO("test", "test", 1l, 2l, Long.valueOf(123), ResourceTag.ResourceObjectType.UserVm, "", "test")); List<String> resourceIds = Arrays.asList("123"); Mockito.when(taggedResourceManagerMock.getUuid("123", ResourceTag.ResourceObjectType.UserVm)).thenReturn("123"); Mockito.when(taggedResourceManagerMock.getResourceId("123", ResourceTag.ResourceObjectType.UserVm)).thenReturn(Long.valueOf(123)); Mockito.<List<? extends ResourceTag>>when(taggedResourceManagerMock.listByResourceTypeAndId(ResourceTag.ResourceObjectType.UserVm, Long.valueOf(123))).thenReturn(resourceTags); Mockito.when(taggedResourceManagerMock.deleteTags(resourceIds, ResourceTag.ResourceObjectType.UserVm, null)).thenReturn(true); Mockito.when(userVmDao.findById(123l)).thenReturn(userVmVoMock); Mockito.when(userVmVoMock.getUuid()).thenReturn("123"); userVmManagerImpl.removeTagsFromVm(Long.valueOf(123)); Assert.assertTrue(taggedResourceManagerMock.deleteTags(resourceIds, ResourceTag.ResourceObjectType.UserVm, null)); }
Source:
<code>public Matrix removeColumn(int j) { <START> return removeColumn(j, this.factory); <END> }</code><technical_language>Unnecessary this</technical_language>

Target:
public Matrix removeColumn(int j) { return removeColumn(j, factory); }
Source:
<code><START> private boolean isEntireColumn(Subfield subfield) <END> { return subfield.getPath().isEmpty(); }</code><technical_language>static, for other helpers</technical_language>

Target:
private static boolean isEntireColumn(Subfield subfield) { return subfield.getPath().isEmpty(); }
Source:
<code>public void configure() throws Exception { <START> String mimetypePattern = "^(text/|application/pdf|application/msword" <END> + "|application/vnd\\.|application/rtf|application/powerpoint" + "|application/postscript).*$"; from("direct-vm:extractFulltext") .routeId("CdrServiceFulltextExtraction") .log(LoggingLevel.DEBUG, "Calling text extraction route for ${headers[org.fcrepo.jms.identifier]}") .filter(simple("${headers[MimeType]} regex '" + mimetypePattern + "'")) .log(LoggingLevel.INFO, "Extracting text from ${headers[org.fcrepo.jms.identifier]}" + " of type ${headers[MimeType]}") .to("direct:fulltext.extraction"); from("direct:fulltext.extraction") .routeId("ExtractingText") .log(LoggingLevel.INFO, "Extracting full text for ${headers[binaryPath]}") .bean(ftProcessor); }</code><technical_language>do putting this in a class constant instead improve visibility/maintainability</technical_language>

Target:
public void configure() throws Exception { onException(Exception.class) .redeliveryDelay("{{error.retryDelay}}") .maximumRedeliveries("{{error.maxRedeliveries}}") .backOffMultiplier(2) .retryAttemptedLogLevel(LoggingLevel.WARN); from("direct-vm:extractFulltext") .routeId("CdrServiceFulltextExtraction") .log(LoggingLevel.DEBUG, "Calling text extraction route for ${headers[org.fcrepo.jms.identifier]}") .filter(simple("${headers[MimeType]} regex '" + MIMETYPE_PATTERN + "'")) .log(LoggingLevel.INFO, "Extracting text from ${headers[org.fcrepo.jms.identifier]}" + " of type ${headers[MimeType]}") .to("direct:fulltext.extraction"); from("direct:fulltext.extraction") .routeId("ExtractingText") .log(LoggingLevel.INFO, "Extracting full text for ${headers[binaryPath]}") .bean(ftProcessor); }
Source:
<code>public void testGetGridLayer() { final DMNGridLayer gridLayer = control.getGridLayer(); <START> assertEquals(gridLayer, <END> control.getGridLayer()); }</code><technical_language>a assertEquals(String message, long expected, long actual) method, do this: java assertEquals("Check instance is re-used", gridLayer, control.getGridLayer());</technical_language>

Target:
public void testGetGridLayer() { final DMNGridLayer gridLayer = control.getGridLayer(); assertEquals("GridLayer instances should be identical.", gridLayer, control.getGridLayer()); }
Source:
<code>public String apply(Entity input) { String hostname = input.getAttribute(getConfig(HOSTNAME_SENSOR)); hostname = DOMAIN_NAME_FIRST_CHAR_MATCHER.negate().trimFrom(hostname); <START> return DOMAIN_NAME_MATCHER.retainFrom(hostname); <END> }</code><technical_language>hostname = DOMAIN_NAME_FIRST_CHAR_MATCHER.negate().trimLeadingFrom(hostname); return DOMAIN_NAME_MATCHER.negate().trimAndCollapseFrom(hostname, '-'); This better, removes disallowed characters start, replaces else disallowed in body of string -. length restrictions too, 63 characters segment 255 characters maximum</technical_language>

Target:
public String apply(Entity input) { String hostname = input.getAttribute(getConfig(HOSTNAME_SENSOR)); hostname = DOMAIN_NAME_FIRST_CHAR_MATCHER.negate().trimFrom(hostname); hostname = DOMAIN_NAME_MATCHER.negate().trimAndCollapseFrom(hostname, '-'); if (hostname.length() > 63) { hostname = hostname.substring(0, 63); } return hostname; }
Source:
<code>public JettyWorkDirValidator() { <START> systemEnvironment = new SystemEnvironment(); <END> }</code><technical_language>change this this(new SystemEnvironment())</technical_language>

Target:
public JettyWorkDirValidator() { this(new SystemEnvironment()); }
Source:
<code>private void addSellOrder(Order order) { SellOrder <START> s <END> = (SellOrder) order; if (sellOrders.containsKey(s.getStockSymbol())) { ArrayList<Order> temp = sellOrders.get(s.getStockSymbol()); temp.add(s); sellOrders.put(s.getStockSymbol(), temp); } else { ArrayList<Order> temp = new ArrayList<Order>(); temp.add(s); sellOrders.put(s.getStockSymbol(), temp); } }</code><technical_language>Rename sellOrderToAdd</technical_language>

Target:
private void addSellOrder(Order order) { SellOrder sellOrderToAdd = (SellOrder) order; if (sellOrders.containsKey(s.getStockSymbol())) { ArrayList<Order> temp = sellOrders.get(s.getStockSymbol()); temp.add(s); sellOrders.put(s.getStockSymbol(), temp); } else { ArrayList<Order> temp = new ArrayList<Order>(); temp.add(s); sellOrders.put(s.getStockSymbol(), temp); } }
Source:
<code>public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { slea.readInt(); int birthday = slea.readInt(); if (!CashOperationHandler.checkBirthday(c, birthday)) { c.announce(MaplePacketCreator.showCashShopMessage((byte) 0xC4)); c.announce(MaplePacketCreator.enableActions()); return; } if(!ServerConstants.ALLOW_CASHSHOP_NAME_CHANGE) { c.announce(MaplePacketCreator.sendNameTransferRules(4)); return; } MapleCharacter chr = c.getPlayer(); if(chr.getLevel() < 10) { c.announce(MaplePacketCreator.sendNameTransferRules(4)); return; } else if(c.getTempBanCalendar() != null && c.getTempBanCalendar().getTimeInMillis() + (30*24*60*60*1000) < Calendar.getInstance().getTimeInMillis()) { c.announce(MaplePacketCreator.sendNameTransferRules(2)); return; } try (Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT completionTime FROM namechanges WHERE characterid=?")) { ps.setInt(1, chr.getId()); ResultSet rs = ps.executeQuery(); while(rs.next()) { Timestamp completedTimestamp = rs.getTimestamp("completionTime"); if(completedTimestamp == null) { c.announce(MaplePacketCreator.sendNameTransferRules(1)); return; } else if(completedTimestamp.getTime() + ServerConstants.NAME_CHANGE_COOLDOWN > System.currentTimeMillis()) { c.announce(MaplePacketCreator.sendNameTransferRules(3)); return; }; } } catch(SQLException e) { e.printStackTrace(); } <START> c.announce(MaplePacketCreator.sendNameTransferRules(0)); <END> }</code><technical_language>Exception call this</technical_language>

Target:
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { slea.readInt(); int birthday = slea.readInt(); if (!CashOperationHandler.checkBirthday(c, birthday)) { c.announce(MaplePacketCreator.showCashShopMessage((byte) 0xC4)); c.announce(MaplePacketCreator.enableActions()); return; } if(!ServerConstants.ALLOW_CASHSHOP_NAME_CHANGE) { c.announce(MaplePacketCreator.sendNameTransferRules(4)); return; } MapleCharacter chr = c.getPlayer(); if(chr.getLevel() < 10) { c.announce(MaplePacketCreator.sendNameTransferRules(4)); return; } else if(c.getTempBanCalendar() != null && c.getTempBanCalendar().getTimeInMillis() + (30*24*60*60*1000) < Calendar.getInstance().getTimeInMillis()) { c.announce(MaplePacketCreator.sendNameTransferRules(2)); return; } try (Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT completionTime FROM namechanges WHERE characterid=?")) { ps.setInt(1, chr.getId()); ResultSet rs = ps.executeQuery(); while(rs.next()) { Timestamp completedTimestamp = rs.getTimestamp("completionTime"); if(completedTimestamp == null) { c.announce(MaplePacketCreator.sendNameTransferRules(1)); return; } else if(completedTimestamp.getTime() + ServerConstants.NAME_CHANGE_COOLDOWN > System.currentTimeMillis()) { c.announce(MaplePacketCreator.sendNameTransferRules(3)); return; }; } } catch(SQLException e) { e.printStackTrace(); return; } c.announce(MaplePacketCreator.sendNameTransferRules(0)); }
Source:
<code>private void updateIndex(String indexName, List<FieldSort> fieldNames) throws QueryException { Misc.checkNotNullOrEmpty(indexName, "indexName"); Changes changes; long lastSequence = sequenceNumberForIndex(indexName); try { do { changes = database.changes(lastSequence, 10000); updateIndex(indexName, fieldNames, changes, lastSequence); lastSequence = changes.getLastSequence(); } while (changes.size() > 0); } catch (DocumentStoreException e) { String message = String.format(Locale.ENGLISH, "Failed to get changes feed from %d", lastSequence); logger.log(Level.SEVERE, message, e); <START> throw new QueryException(e.getCause()); <END> } }</code><technical_language>wrap DocmentStoreException here</technical_language>

Target:
private void updateIndex(String indexName, List<FieldSort> fieldNames) throws QueryException { Misc.checkNotNullOrEmpty(indexName, "indexName"); Changes changes; long lastSequence = sequenceNumberForIndex(indexName); try { do { changes = database.changes(lastSequence, 10000); updateIndex(indexName, fieldNames, changes, lastSequence); lastSequence = changes.getLastSequence(); } while (changes.size() > 0); } catch (DocumentStoreException e) { String message = String.format(Locale.ENGLISH, "Failed to get changes feed from %d", lastSequence); logger.log(Level.SEVERE, message, e); throw new QueryException(message, e.getCause()); } }
Source:
<code>public void testShareable() { Shareable myShareable = new Shareable() { @Override public Shareable copy() { return this; } }; JsonObject json = new JsonObject(); json.put("0", myShareable); assertEquals(myShareable, json.getValue("0")); assertSame(myShareable, json.getValue("0")); JsonObject json2 = json.copy(); <START> } <END></code><technical_language>testing copy() operation assertion before, I unwrap underlying map check map contains</technical_language>

Target:
public void testShareable() { final AtomicInteger cnt = new AtomicInteger(0); Shareable myShareable = new Shareable() { @Override public Shareable copy() { cnt.incrementAndGet(); return this; } }; JsonObject json = new JsonObject(); json.put("0", myShareable); assertEquals(myShareable, json.getValue("0")); assertSame(myShareable, json.getValue("0")); assertEquals(0, cnt.get()); JsonObject json2 = json.copy(); assertEquals(1, cnt.get()); assertEquals(myShareable, json2.getValue("0")); assertSame(myShareable, json2.getValue("0")); }