auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> private void checkAssertions(final String url, final Map<String,?> flags, final Map<?, ?> assertions) { <END> for (final Map.Entry<?, ?> entry : assertions.entrySet()) { if (Objects.equal(entry.getKey(), "regex")) { LOG.info("Testing if url matches regex [{}]", new Object[]{url, entry.getValue()}); assertContentEventuallyMatches( flags, url, TypeCoercions.coerce(entry.getValue(), String.class)); } else if (Objects.equal(entry.getKey(), "string")) { LOG.debug("Testing if url contains string [{}]", new Object[]{url, entry.getValue()}); assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class)); } else if (Objects.equal(entry.getKey(), "status")) { LOG.debug("Testing if url returns status code [{}]", new Object[]{url, entry.getValue()}); assertHttpStatusCodeEventuallyEquals(flags, url, TypeCoercions.coerce(entry.getValue(), Integer.class)); } } }</code><technical_language>this logic pulled out a convenience class, e.g. TestFrameworkAssertions in time set of assertions is extensible catalog (this is work BrooklynTypeRegister.createBean)</technical_language>

Target:
private void checkAssertions(final String url, final Map<String, ?> flags, final Map<?, ?> assertions) { for (final Map.Entry<?, ?> entry : assertions.entrySet()) { if (Objects.equal(entry.getKey(), "regex")) { LOG.info("Testing if url matches regex [{}]", new Object[]{url, entry.getValue()}); assertContentEventuallyMatches(flags, url, TypeCoercions.coerce(entry.getValue(), String.class)); } else if (Objects.equal(entry.getKey(), "bodyContains")) { LOG.debug("Testing if url contains string [{}]", new Object[]{url, entry.getValue()}); assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class)); } else if (Objects.equal(entry.getKey(), "status")) { LOG.debug("Testing if url returns status code [{}]", new Object[]{url, entry.getValue()}); assertHttpStatusCodeEventuallyEquals(flags, url, TypeCoercions.coerce(entry.getValue(), Integer.class)); } } }
Source:
<code>public Checkpoint readLastCheckpoint(TaskName taskName) { if (!taskNames.contains(taskName)) { throw new SamzaException("writing checkpoint of unregistered task"); } String partitionQueryKey = taskName.toString(); String partitionFilter = TableQuery.generateFilterCondition( PARTITION_KEY, TableQuery.QueryComparisons.EQUAL, partitionQueryKey); TableQuery<TaskCheckpointEntity> partitionQuery = TableQuery.from(TaskCheckpointEntity.class) .where(partitionFilter); Map<SystemStreamPartition, String> offsets = new HashMap<>(); for (TaskCheckpointEntity taskCheckpointEntity : cloudTable.execute(partitionQuery)) { String systemName = taskCheckpointEntity.getRowKey(); String streamName = taskCheckpointEntity.getStreamName(); int partitionId = taskCheckpointEntity.getPartitionId(); offsets.put(new SystemStreamPartition(systemName, streamName, new Partition(partitionId)), taskCheckpointEntity.getOffset()); } <START> return new Checkpoint(offsets); <END> }</code><technical_language>nice wrap this in ImmutableMap guard mutations map. new Checkpoint(ImmutableMap.of(offsets)))</technical_language>

Target:
public Checkpoint readLastCheckpoint(TaskName taskName) { if (!taskNames.contains(taskName)) { throw new SamzaException("reading checkpoint of unregistered/unwritten task"); } String partitionQueryKey = taskName.toString(); String partitionFilter = TableQuery.generateFilterCondition( PARTITION_KEY, TableQuery.QueryComparisons.EQUAL, partitionQueryKey); TableQuery<TaskCheckpointEntity> query = TableQuery.from(TaskCheckpointEntity.class).where(partitionFilter); ImmutableMap.Builder<SystemStreamPartition, String> builder = ImmutableMap.builder(); try { for (TaskCheckpointEntity taskCheckpointEntity : cloudTable.execute(query)) { String serializedSSP = taskCheckpointEntity.getRowKey(); builder.put(deserializeSystemStreamPartition(serializedSSP), taskCheckpointEntity.getOffset()); } } catch (NoSuchElementException e) { LOG.warn("No checkpoints found found for registered taskName={}", taskName); return null; } LOG.debug("Received checkpoint state for taskName=%s", taskName); return new Checkpoint(builder.build()); }
Source:
<code>public SettingsDTO fromSettingstoDTO(Boolean isUserAvailable, Boolean moneatizationEnabled) throws APIManagementException { SettingsDTO settingsDTO = new SettingsDTO(); if (isUserAvailable) { settingsDTO.setGrantTypes(APIUtil.getGrantTypes()); settingsDTO.setScopes(GetScopeList()); settingsDTO.setApplicationSharingEnabled(APIUtil.isMultiGroupAppSharingEnabled()); settingsDTO.setMapExistingAuthApps(APIUtil.isMapExistingAuthAppsEnabled()); Map<String, Environment> environments = APIUtil.getEnvironments(); <START> if (environments.size()==1){ <END> Map.Entry<String,Environment> entry = environments.entrySet().iterator().next(); Environment singleEnvironment = environments.get(entry.getKey()); settingsDTO.apiGatewayEndpoint(singleEnvironment.getApiGatewayEndpoint()); } else { for (Map.Entry<String, Environment> entry : environments.entrySet()) { Environment multipleEnvironment = environments.get(entry.getKey()); if (multipleEnvironment.isDefault()) { settingsDTO.apiGatewayEndpoint(multipleEnvironment.getApiGatewayEndpoint()); break; } } Map.Entry<String,Environment> entry = environments.entrySet().iterator().next(); Environment singleEnvironment = environments.get(entry.getKey()); settingsDTO.apiGatewayEndpoint(singleEnvironment.getApiGatewayEndpoint()); } } else { settingsDTO.setScopes(GetScopeList()); settingsDTO.setApplicationSharingEnabled(APIUtil.isMultiGroupAppSharingEnabled()); settingsDTO.setMapExistingAuthApps(APIUtil.isMapExistingAuthAppsEnabled()); settingsDTO.setMonetizationEnabled(moneatizationEnabled); } return settingsDTO; }</code><technical_language>Please format code</technical_language>

Target:
public SettingsDTO fromSettingstoDTO(Boolean isUserAvailable, Boolean moneatizationEnabled) throws APIManagementException { SettingsDTO settingsDTO = new SettingsDTO(); if (isUserAvailable) { settingsDTO.setGrantTypes(APIUtil.getGrantTypes()); settingsDTO.setScopes(GetScopeList()); settingsDTO.setApplicationSharingEnabled(APIUtil.isMultiGroupAppSharingEnabled()); settingsDTO.setMapExistingAuthApps(APIUtil.isMapExistingAuthAppsEnabled()); Map<String, Environment> environments = APIUtil.getEnvironments(); if (environments.size() == 0) { settingsDTO.apiGatewayEndpoint("http://localhost:8280,https://localhost:8243"); } else { for (Map.Entry<String, Environment> entry : environments.entrySet()) { Environment environment = environments.get(entry.getKey()); if (environment.isDefault()) { settingsDTO.apiGatewayEndpoint(environment.getApiGatewayEndpoint()); break; } } if (settingsDTO.getApiGatewayEndpoint() == null) { Map.Entry<String, Environment> entry = environments.entrySet().iterator().next(); Environment environment = environments.get(entry.getKey()); settingsDTO.apiGatewayEndpoint(environment.getApiGatewayEndpoint()); } } } else { settingsDTO.setScopes(GetScopeList()); settingsDTO.setApplicationSharingEnabled(APIUtil.isMultiGroupAppSharingEnabled()); settingsDTO.setMapExistingAuthApps(APIUtil.isMapExistingAuthAppsEnabled()); settingsDTO.setMonetizationEnabled(moneatizationEnabled); } return settingsDTO; }
Source:
<code>public void configure(H http) throws Exception { BearerTokenResolver resolver = getBearerTokenResolver(http); resolver = postProcess(resolver); this.matcher.setResolver(resolver); AuthenticationManager manager = http.getSharedObject(AuthenticationManager.class); BearerTokenAuthenticationFilter filter = new BearerTokenAuthenticationFilter(manager); filter.setBearerTokenResolver(resolver); filter = postProcess(filter); http.addFilterBefore(filter, BasicAuthenticationFilter.class); if (this.jwtConfigurer != null) { JwtDecoder decoder = getJwtDecoder(http); if (decoder != null) { decoder = postProcess(decoder); JwtAuthenticationProvider provider = new JwtAuthenticationProvider(decoder); provider = postProcess(provider); http.authenticationProvider(provider); } else { throw new BeanCreationException("Jwt is the only supported format for bearer tokens " + "in Spring Security and no instance of JwtDecoder could be found. Make sure to specify " + "a jwk set uri by doing http.oauth2().resourceServer().jwt().jwkSetUri(uri)"); } <START> } <END> }</code><technical_language>Change this method set a JwkDecoder keeping track of uri. For example: java this.jwtDecoder = new NimbusJwtDecoderJwkSupport(uri); This is more flexible for future need track of member variables</technical_language>

Target:
public void configure(H http) throws Exception { BearerTokenResolver bearerTokenResolver = getBearerTokenResolver(); this.requestMatcher.setBearerTokenResolver(bearerTokenResolver); AuthenticationManager manager = http.getSharedObject(AuthenticationManager.class); BearerTokenAuthenticationFilter filter = new BearerTokenAuthenticationFilter(manager); filter.setBearerTokenResolver(bearerTokenResolver); filter = postProcess(filter); http.addFilterBefore(filter, BasicAuthenticationFilter.class); JwtDecoder decoder = this.jwtConfigurer.getJwtDecoder(); if (decoder != null) { JwtAuthenticationProvider provider = new JwtAuthenticationProvider(decoder); provider = postProcess(provider); http.authenticationProvider(provider); } else { throw new IllegalStateException("Jwt is the only supported format for bearer tokens " + "in Spring Security and no instance of JwtDecoder could be found. Make sure to specify " + "a jwk set uri by doing http.oauth2().resourceServer().jwt().jwkSetUri(uri)"); } }
Source:
<code>public void retainData(final long n) { long curRetainedDataPoints = retained.addAndGet(n); <START> if (curRetainedDataPoints > 500_000) { <END> long total = quotaWatchers.stream().map(QuotaWatcher::getRetainData).reduce(0L, Long::sum); log.info("Total: {}; watchers: {}; Data points retained: {}; added: {}", total, quotaWatchers.size(), curRetainedDataPoints, n); } throwIfViolated(); }</code><technical_language>I this is temp code raw number in a const please</technical_language>

Target:
public void retainData(final long n) { long curRetainedDataPoints = retained.addAndGet(n); if (curRetainedDataPoints > LOGLIMIT) { long total = quotaWatchers.stream().map(QuotaWatcher::getRetainData) .reduce(0L, Long::sum); log.info("Data Points RETAINED: Instance {}; This Query: {}; Delta: " + "(# Wathcers: {})", total, curRetainedDataPoints, n, quotaWatchers.size()); } throwIfViolated(); }
Source:
<code>public Template saveTemplate(final IHTMLPage page, final User user, final PageForm pageForm) throws BadRequestException, DotDataException, DotSecurityException, IOException { try { final Host host = getHost(pageForm.getHostId(), user); Template template = getTemplate(page, user, pageForm); template.setDrawed(true); pageForm.getChanges().forEach(containerUUIDChanged -> { ContainerUUID old = containerUUIDChanged.getOld(); ContainerUUID aNew = containerUUIDChanged.getNew(); try { <START> MultiTreeFactory.updateMultiTree(page.getIdentifier(), old.getIdentifier(), old.getUUID(), aNew.getUUID()); <END> } catch (DotDataException e) { e.printStackTrace(); } }); return this.templateAPI.saveTemplate(template, host, user, false); } catch (Exception e) { throw new DotRuntimeException(e); } }</code><technical_language>If a factory in mind annotated method WrapInTransaction</technical_language>

Target:
public Template saveTemplate(final IHTMLPage page, final User user, final PageForm pageForm) throws BadRequestException, DotDataException, DotSecurityException, IOException { try { final Host host = getHost(pageForm.getHostId(), user); Template template = getTemplate(page, user, pageForm); template.setDrawed(true); pageForm.getChanges().forEach(containerUUIDChanged -> { final ContainerUUID old = containerUUIDChanged.getOld(); final ContainerUUID aNew = containerUUIDChanged.getNew(); try { multiTreeAPI.updateMultiTree(page.getIdentifier(), old.getIdentifier(), old.getUUID(), aNew.getUUID()); } catch (DotDataException e) { Logger.error(this.getClass(),"Exception on saveTemplate exception message: " + e.getMessage(), e); } }); return this.templateAPI.saveTemplate(template, host, user, false); } catch (Exception e) { throw new DotRuntimeException(e); } }
Source:
<code><START> public void setOutputStream(PrintStream outputStream) { <END> this.outputStream = outputStream; }</code><technical_language>this package private</technical_language>

Target:
void setOutputStream(PrintStream outputStream) { this.outputStream = outputStream; }
Source:
<code>protected void executeVmCommand() { RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(snapshot, getVmId()); runInternalAction(ActionType.RemoveMemoryVolumes, parameters); <START> snapshot.setMemoryDiskId(null); snapshot.setMetadataDiskId(null); snapshotDao.update(snapshot); <END> setSucceeded(true); }</code><technical_language>plan clear entity first</technical_language>

Target:
protected void executeVmCommand() { snapshot.setMemoryDiskId(null); snapshot.setMetadataDiskId(null); snapshotDao.update(snapshot); RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(snapshot, getVmId()); runInternalAction(ActionType.RemoveMemoryVolumes, parameters); setSucceeded(true); }
Source:
<code>public static Set<String> getMappingTargetNamesBy(Predicate<Mapping> predicate, Set<Mapping> mappings) { <START> return mappings.stream().filter( predicate ).map( Mapping::getTargetName ).collect( Collectors.toSet() ); <END> }</code><technical_language>Do need preserver ordering? If need do Collectors.toCollection( LinkedHashSet::new )</technical_language>

Target:
public static Set<String> getMappingTargetNamesBy(Predicate<Mapping> predicate, Set<Mapping> mappings) { return mappings.stream() .filter( predicate ) .map( Mapping::getTargetName ) .collect( Collectors.toCollection( LinkedHashSet::new ) ); }
Source:
<code>private void initGuidepostDepth() throws IOException, SQLException { if (guidePostPerRegionBytes != null || guidePostWidthBytes != null) { getGuidePostDepthFromStatement(); LOG.info("Guide post depth determined from SQL statement: " + guidePostDepth); } else { long guidepostWidth = getGuidePostDepthFromSystemCatalog(getHTableForSystemCatalog()); <START> if (guidepostWidth >= 0) { <END> this.guidePostDepth = guidepostWidth; LOG.info("Guide post depth determined from SYSTEM.CATALOG: " + guidePostDepth); } else { this.guidePostDepth = StatisticsUtil.getGuidePostDepth( configuration.getInt( QueryServices.STATS_GUIDEPOST_PER_REGION_ATTRIB, QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_PER_REGION), configuration.getLong( QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_WIDTH_BYTES), region.getTableDesc()); LOG.info("Guide post depth determined from global configuration: " + guidePostDepth); } } }</code><technical_language>nit: > 0, 0 is logically a bad width</technical_language>

Target:
private void initGuidepostDepth() throws IOException, SQLException { if (guidePostPerRegionBytes != null || guidePostWidthBytes != null) { getGuidePostDepthFromStatement(); LOG.info("Guide post depth determined from SQL statement: " + guidePostDepth); } else { long guidepostWidth = getGuidePostDepthFromSystemCatalog(); if (guidepostWidth >= 0) { this.guidePostDepth = guidepostWidth; LOG.info("Guide post depth determined from SYSTEM.CATALOG: " + guidePostDepth); } else { this.guidePostDepth = StatisticsUtil.getGuidePostDepth( configuration.getInt( QueryServices.STATS_GUIDEPOST_PER_REGION_ATTRIB, QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_PER_REGION), configuration.getLong( QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_WIDTH_BYTES), region.getTableDesc()); LOG.info("Guide post depth determined from global configuration: " + guidePostDepth); } } }
Source:
<code>protected Collection<DRepresentationDescriptor> getRepresentationDescriptors(Session session, String key, EObject value) { Collection<DRepresentationDescriptor> reps = Lists.newArrayList(); for (EObject repDescriptor : session.getServices().getCustomData(key, value)) { if (repDescriptor instanceof DRepresentationDescriptor && <START> isSupported((DRepresentationDescriptor) repDescriptor)) { <END> reps.add((DRepresentationDescriptor) repDescriptor); } } return reps; }</code><technical_language>isSupported((DRepresentationDescriptor) repDescriptor) is compiling this method updated in a commit</technical_language>

Target:
protected Collection<DRepresentationDescriptor> getRepresentationDescriptors(Session session, String key, EObject value) { Collection<DRepresentationDescriptor> reps = Lists.newArrayList(); for (EObject repDescriptor : session.getServices().getCustomData(key, value)) { if (repDescriptor instanceof DRepresentationDescriptor && isSupported(((DRepresentationDescriptor) repDescriptor).getRepresentation())) { reps.add((DRepresentationDescriptor) repDescriptor); } } return reps; }
Source:
<code>private void checkCookieBuilder(AssignmentExpressionTree assignment) { if (assignment.expression().is(Tree.Kind.METHOD_INVOCATION) <START> && assignment.variable().is(Tree.Kind.IDENTIFIER)) { <END> MethodInvocationTree mit = (MethodInvocationTree) assignment.expression(); if (PLAY_COOKIE_BUILDER.matches(mit) && isIgnoredCookieName(mit.arguments())) { ignoredVariables.add((VariableSymbol) ((IdentifierTree) assignment.variable()).symbol()); } } }</code><technical_language>supporting Tree.Kind.IDENTIFIER Tree.Kind.MEMBER_SELECT, FP: class S3330 { play.mvc.Http.CookieBuilder xsfrToken10; Cookie xsfrToken() { this.xsfrToken10 = play.mvc.Http.Cookie.builder("XSRF-TOKEN", "2"); this.xsfrToken10.withHttpOnly(false); // false-positive } }</technical_language>

Target:
private void checkCookieBuilder(AssignmentExpressionTree assignment) { if (assignment.expression().is(Tree.Kind.METHOD_INVOCATION) && (assignment.variable().is(Tree.Kind.IDENTIFIER) || assignment.variable().is(Tree.Kind.MEMBER_SELECT))) { MethodInvocationTree mit = (MethodInvocationTree) assignment.expression(); VariableSymbol variableSymbol = getVariableSymbol(assignment); if (variableSymbol != null) { addToIgnoredVariables(variableSymbol, mit); } } }
Source:
<code>public PenaltyCodesManager(ScoreBoard parent) { super(parent, null, "", ScoreBoard.Child.PENALTY_CODES, PenaltyCodesManager.class, Child.class); this.parent = parent; <START> parent.addScoreBoardListener(new ConditionalScoreBoardListener(Rulesets.class, Rulesets.Child.CURRENT_RULE, rulesetChangeListener)); <END> }</code><technical_language>initialize definitions</technical_language>

Target:
public PenaltyCodesManager(ScoreBoard parent) { super(parent, null, "", ScoreBoard.Child.PENALTY_CODES, PenaltyCodesManager.class, Child.class); this.parent = parent; loadFromJSON(parent.getRulesets().get(Rule.PENALTIES_FILE)); parent.addScoreBoardListener(new ConditionalScoreBoardListener(Rulesets.class, Rulesets.Child.CURRENT_RULE, rulesetChangeListener)); }
Source:
<code>protected boolean supports(Class<?> clazz) { <START> return true; <END> }</code><technical_language>do require Serializable</technical_language>

Target:
protected boolean supports(Class<?> clazz) { return Serializable.class.isAssignableFrom(clazz); }
Source:
<code>public void testSetMigration() { dao.setNetworkExclusivelyAsMigration(existingNetworkCluster.getClusterId(), existingNetworkCluster.getNetworkId()); List<NetworkCluster> allForCluster = dao.getAllForCluster(existingNetworkCluster.getClusterId()); for (NetworkCluster net : allForCluster) { <START> if (net.getClusterId().equals(existingNetworkCluster.getClusterId()) <END> && net.getNetworkId().equals(existingNetworkCluster.getNetworkId())) { assertTrue(net.isMigration()); } else { assertFalse(net.isMigration()); } } }</code><technical_language>simply compare "getId()" properties</technical_language>

Target:
public void testSetMigration() { dao.setNetworkExclusivelyAsMigration(existingNetworkCluster.getClusterId(), existingNetworkCluster.getNetworkId()); List<NetworkCluster> allForCluster = dao.getAllForCluster(existingNetworkCluster.getClusterId()); for (NetworkCluster net : allForCluster) { if (net.getId().equals(existingNetworkCluster.getId())) { assertTrue(net.isMigration()); } else { assertFalse(net.isMigration()); } } }
Source:
<code>ForeignHost presend(long hsId, VoltMessage message) { int hostId = (int)hsId; if (hostId == m_localHostId) { Mailbox mbox = m_siteMailboxes.get(hsId); if (mbox != null) { mbox.deliver(message); return null; } else { m_networkLog.info("Mailbox is not registered for site id " + CoreUtils.getSiteIdFromHSId(hsId)); return null; } } ImmutableCollection<ForeignHost> fhosts = m_foreignHosts.get(hostId); if (fhosts.isEmpty()) { if (!m_knownFailedHosts.containsKey(hostId)) { m_networkLog.warn( "Attempted to send a message to foreign host with id " + hostId + " but there is no such host."); } return null; } ForeignHost fhost = null; if (fhosts.size() == 1 || CoreUtils.getSiteIdFromHSId(hsId) < 0 ) { fhost = getPrimary(fhosts, hostId); } else { if (m_hasAllSecondaryConnectionCreated) { fhost = m_fhMapping.get(hsId); if (fhost == null) { int index = Math.abs(m_nextForeignHost.getAndIncrement() % fhosts.size()); fhost = (ForeignHost) fhosts.toArray()[index]; <START> if (m_hostLog.isDebugEnabled()) { <END> m_hostLog.debug("bind " + CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId) + " to " + fhost.hostnameAndIPAndPort()); } bindForeignHost(hsId, fhost); } } else { fhost = getPrimary(fhosts, hostId); } } if (!fhost.isUp()) { if (!m_shuttingDown) { m_networkLog.info("Attempted delivery of message to failed site: " + CoreUtils.hsIdToString(hsId)); } return null; } return fhost; }</code><technical_language>rename static loggers , remove "m_"</technical_language>

Target:
ForeignHost presend(long hsId, VoltMessage message) { int hostId = (int)hsId; if (hostId == m_localHostId) { Mailbox mbox = m_siteMailboxes.get(hsId); if (mbox != null) { mbox.deliver(message); return null; } else { networkLog.info("Mailbox is not registered for site id " + CoreUtils.getSiteIdFromHSId(hsId)); return null; } } ImmutableCollection<ForeignHost> fhosts = m_foreignHosts.get(hostId); if (fhosts.isEmpty()) { if (!m_knownFailedHosts.containsKey(hostId)) { networkLog.warn( "Attempted to send a message to foreign host with id " + hostId + " but there is no such host."); } return null; } ForeignHost fhost = null; if (fhosts.size() == 1 || CoreUtils.getSiteIdFromHSId(hsId) < 0 ) { fhost = getPrimary(fhosts, hostId); } else { if (m_hasAllSecondaryConnectionCreated) { fhost = m_fhMapping.get(hsId); if (fhost == null) { int index = Math.abs(m_nextForeignHost.getAndIncrement() % fhosts.size()); fhost = (ForeignHost) fhosts.toArray()[index]; if (hostLog.isDebugEnabled()) { hostLog.debug("bind " + CoreUtils.getHostIdFromHSId(hsId) + ":" + CoreUtils.getSiteIdFromHSId(hsId) + " to " + fhost.hostnameAndIPAndPort()); } bindForeignHost(hsId, fhost); } } else { fhost = getPrimary(fhosts, hostId); } } if (!fhost.isUp()) { if (!m_shuttingDown) { networkLog.info("Attempted delivery of message to failed site: " + CoreUtils.hsIdToString(hsId)); } return null; } return fhost; }
Source:
<code>public void cacheSerializers() throws Exception { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder() .withResourcePools(ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB)) <START> .withKeySerializer((Serializer) new LongSerializer()) END> .withValueSerializer(new CharSequenceSerializer()) .buildConfig(Long.class, String.class); CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withCache("cache", cacheConfiguration) .build(true); Cache<Long, String> cache = cacheManager.getCache("cache", Long.class, String.class); cache.put(1L, "one"); assertThat(cache.get(1L), equalTo("one")); cacheManager.close(); }</code><technical_language>more, fishy cast</technical_language>

Target:
public void cacheSerializers() throws Exception { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder() .withResourcePools(ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB)) .withKeySerializer((Serializer) new LongSerializer()) .withValueSerializer((Serializer) new CharSequenceSerializer()) .buildConfig(Long.class, String.class); CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withCache("cache", cacheConfiguration) .build(true); Cache<Long, String> cache = cacheManager.getCache("cache", Long.class, String.class); cache.put(1L, "one"); assertThat(cache.get(1L), equalTo("one")); cacheManager.close(); }
Source:
<code>public DatabaseUserConfigLoader(HiveConf conf) throws UserConfigLoaderException { super(conf); String className = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_DRIVER_NAME); String jdbcUrl = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_URL); String userName = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_USERNAME); String pass = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_PASSWORD); <START> if(pass == null) { <END> pass = ""; } querySql = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_QUERY); keys = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_KEYS).split("\\s*,\\s*", -1); if(anyNull(className, jdbcUrl, userName, pass, querySql, keys)) { throw new UserConfigLoaderException("You need to specify all of the following in conf: [" + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_DRIVER_NAME + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_URL + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_USERNAME + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_PASSWORD + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_QUERY + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_KEYS + ", " + "]"); } ds = getDataSourceFromConf(conf); }</code><technical_language>handled default in conf.get</technical_language>

Target:
public DatabaseUserConfigLoader(HiveConf conf) throws UserConfigLoaderException { super(conf); String className = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_DRIVER_NAME); String jdbcUrl = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_URL); String userName = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_USERNAME); String pass = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_PASSWORD, ""); querySql = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_QUERY); keys = conf.get(GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_KEYS).split("\\s*,\\s*", -1); if(anyNull(className, jdbcUrl, userName, pass, querySql, keys)) { throw new UserConfigLoaderException("You need to specify all of the following in conf: [" + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_DRIVER_NAME + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_URL + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_USERNAME + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_JDBC_PASSWORD + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_QUERY + ", " + GrillConfConstants.GRILL_SERVER_USER_RESOLVER_DB_KEYS + ", " + "]"); } ds = getDataSourceFromConf(conf); }
Source:
<code>public ServerEvaluationStrategyProvider(Map<String, ServerEvaluationStrategy> strategies, @Named("che.docker.server_evaluation_strategy") String chosenStrategy) { if (strategies.containsKey(chosenStrategy)) { this.strategy = strategies.get(chosenStrategy); } else { <START> LOG.warn(String.format("Property che.docker.server_evaluation_strategy=%s" <END> + " does not refer to implemented strategy. Using default.", chosenStrategy)); this.strategy = strategies.get(DEFAULT_STRATEGY_NAME); } }</code><technical_language>hard debug realize happened if developer a typo in strategy name for example. is fail component start in case instead of usage of default strategy</technical_language>

Target:
public ServerEvaluationStrategyProvider(Map<String, ServerEvaluationStrategy> strategies, @Named("che.docker.server_evaluation_strategy") String chosenStrategy) { if (strategies.containsKey(chosenStrategy)) { this.strategy = strategies.get(chosenStrategy); } else { this.strategy = null; } this.chosenStrategy = chosenStrategy; }
Source:
<code><START> private NetworkClusterDao getNetworkClusterDao() { <END> return DbFacade.getInstance().getNetworkClusterDao(); }</code><technical_language>removal of static patch fail compilation</technical_language>

Target:
private static NetworkClusterDao getNetworkClusterDao() { return DbFacade.getInstance().getNetworkClusterDao(); }
Source:
<code>public Map<String, FieldValueRecommender> createDefaultParametersToOptimize() { Map<String, FieldValueRecommender> parametersToOptimize = Maps.newHashMap(); parametersToOptimize.putAll(wrappedBuilderBuilder.createDefaultParametersToOptimize()); <START> parametersToOptimize.put("halfLifeOfNegative", new FixedOrderRecommender(5, 10, 20)); <END> parametersToOptimize.put("halfLifeOfPositive", new FixedOrderRecommender(5, 10, 20)); return parametersToOptimize; }</code><technical_language>Prefer constants for string literals</technical_language>

Target:
public Map<String, FieldValueRecommender> createDefaultParametersToOptimize() { Map<String, FieldValueRecommender> parametersToOptimize = Maps.newHashMap(); parametersToOptimize.putAll(wrappedBuilderBuilder.createDefaultParametersToOptimize()); parametersToOptimize.put(HALF_LIFE_OF_NEGATIVE, new FixedOrderRecommender(5.0, 10.0, 20.0)); parametersToOptimize.put(HALF_LIFE_OF_POSITIVE, new FixedOrderRecommender(5.0, 10.0, 20.0)); return parametersToOptimize; }
Source:
<code><START> public void updateModel(final @Nullable ISegmentStore<ISegment> dataInput) { <END> Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (!fTableViewer.getTable().isDisposed()) { ISegmentStore<ISegment> data = dataInput; ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); if (trace == null) { fAnalysisModule = null; } else { fAnalysisModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID); } fTableViewer.getTable().setTopIndex(0); fTableViewer.setSelection(StructuredSelection.EMPTY); if (data == null) { fTableViewer.setInput(null); fTableViewer.setItemCount(0); return; } fTableViewer.setInput(data); if (data.getNbElements() <= Integer.MAX_VALUE) { fTableViewer.setItemCount((int) data.getNbElements()); } else { fTableViewer.setItemCount(Integer.MAX_VALUE); } } } }); }</code><technical_language>do final TableViewer viewer = getTableViewer(); "viewer" in runnable below. This guarantee viewer change while working it</technical_language>

Target:
public void updateModel(final @Nullable ISegmentStore<ISegment> dataInput) { final TableViewer tableViewer = getTableViewer(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (!tableViewer.getTable().isDisposed()) { ISegmentStore<ISegment> data = dataInput; ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); if (trace == null) { fAnalysisModule = null; } else { fAnalysisModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID); } tableViewer.getTable().setTopIndex(0); tableViewer.setSelection(StructuredSelection.EMPTY); if (data == null) { tableViewer.setInput(null); tableViewer.setItemCount(0); return; } tableViewer.setInput(data); if (data.getNbElements() <= Integer.MAX_VALUE) { tableViewer.setItemCount((int) data.getNbElements()); } else { tableViewer.setItemCount(Integer.MAX_VALUE); } } } }); }
Source:
<code>RuntimeException closeZombieTasks(final Set<TaskId> lostTasks, final List<TopicPartition> lostTaskChangelogs) { final AtomicReference<RuntimeException> firstException = new AtomicReference<>(null); for (final TaskId id : lostTasks) { if (suspended.containsKey(id)) { log.debug("Closing the suspended stream task {}.", id); firstException.compareAndSet(null, closeSuspended(true, suspended.get(id))); } else if (created.containsKey(id)) { log.debug("Closing the created stream task {}.", id); firstException.compareAndSet(null, closeNonRunning(true, created.get(id), lostTaskChangelogs)); } else if (restoring.containsKey(id)) { log.debug("Closing the restoring stream task {}.", id); firstException.compareAndSet(null, closeRestoring(true, created.get(id), lostTaskChangelogs)); } else if (running.containsKey(id)) { log.debug("Closing the running stream task {}.", id); firstException.compareAndSet(null, closeRunning(true, running.get(id), lostTaskChangelogs)); } else { <START> log.warn("Skipping closing the lost stream task as it was already removed.", id); <END> } } prevActiveTasks.clear(); prevActiveTasks.addAll(running.keySet()); if (!prevActiveTasks.isEmpty()) { log.error("Found still running after closing all tasks lost as zombies", taskTypeName); firstException.compareAndSet(null, new IllegalStateException("Not all lost tasks were closed as zombies")); } return firstException.get(); }</code><technical_language>nit: lost stream task -> zombie stream task</technical_language>

Target:
RuntimeException closeZombieTasks(final Set<TaskId> lostTasks, final List<TopicPartition> lostTaskChangelogs) { final AtomicReference<RuntimeException> firstException = new AtomicReference<>(null); for (final TaskId id : lostTasks) { if (suspended.containsKey(id)) { log.debug("Closing the zombie suspended stream task {}.", id); firstException.compareAndSet(null, closeSuspended(true, suspended.get(id))); } else if (created.containsKey(id)) { log.debug("Closing the zombie created stream task {}.", id); firstException.compareAndSet(null, closeNonRunning(true, created.get(id), lostTaskChangelogs)); } else if (restoring.containsKey(id)) { log.debug("Closing the zombie restoring stream task {}.", id); firstException.compareAndSet(null, closeRestoring(true, created.get(id), lostTaskChangelogs)); } else if (running.containsKey(id)) { log.debug("Closing the zombie running stream task {}.", id); firstException.compareAndSet(null, closeRunning(true, running.get(id), lostTaskChangelogs)); } else { log.warn("Skipping closing the zombie stream task as it was already removed.", id); } } prevActiveTasks.clear(); prevActiveTasks.addAll(running.keySet()); if (!prevActiveTasks.isEmpty()) { log.error("Found the still running stream tasks after closing all tasks lost as zombies", prevActiveTasks); firstException.compareAndSet(null, new IllegalStateException("Not all lost tasks were closed as zombies")); } return firstException.get(); }
Source:
<code>public void testLazyORFull2() { Container rc = Container.rangeOfOnes(0, 1 << 15); ArrayContainer ac = new ArrayContainer((1 << 15) - 200, 1 << 16); <START> Container rbc = rc.lazyOR(ac); <END> assertEquals(1 << 16, rbc.getCardinality()); assertThat(rbc, instanceOf(RunContainer.class)); }</code><technical_language>is optimization missing here. a rbc... good job done far, easy for understand I :wink:</technical_language>

Target:
public void testLazyORFull2() { Container rc = Container.rangeOfOnes((1 << 10) - 200, 1 << 16); ArrayContainer ac = new ArrayContainer(0, 1 << 10); Container rbc = rc.lazyOR(ac); assertEquals(1 << 16, rbc.getCardinality()); assertThat(rbc, instanceOf(RunContainer.class)); }
Source:
<code>public static void main(String[] args) { List<String> argsList = new ArrayList<>(); argsList.addAll(Arrays.asList(args)); boolean hasServerPort = false; for (String arg : argsList) { if (arg.contains(SERVER_PORT_OPTION)) { hasServerPort = true; <START> return; <END> } } if (!hasServerPort) { argsList.add("--" + SERVER_PORT_OPTION + "=9000"); } SpringApplication.run(HttpSourceApplication.class, argsList.toArray(new String[0])); }</code><technical_language>I return is intentional here</technical_language>

Target:
public static void main(String[] args) { SpringApplication.run(HttpSourceApplication.class, args); }
Source:
<code>private void handlePlusMinus(SymbolicValue left, SymbolicValue right) { if (isZero(left) && isZero(right)) { deferConstraint(Status.ZERO); <START> } else if ((isZero(left) && isNonZero(right)) || (isNonZero(left) && isZero(right))) { <END> deferConstraint(Status.UNDETERMINED); } }</code><technical_language>This is in essence assignement. this method simplified handle fact if left is zero, resulting SV is right SV</technical_language>

Target:
private void handlePlusMinus(SymbolicValue left, SymbolicValue right) { boolean leftIsZero = isZero(left); if (leftIsZero || isZero(right)) { reuseSymbolicValue(leftIsZero ? right : left); } }
Source:
<code>private int validate (String string) { if (string.length() != 8) { throw new StorageException("Date field should be exactly 8 characters long."); } <START> int year = Integer.parseInt(string.substring(0, 4)); <END> int month = Integer.parseInt(string.substring(4, 6)); int day = Integer.parseInt(string.substring(6, 8)); if (year < 2000 || year > 2100) { throw new StorageException("Date year out of range 2000-2100: " + year); } if (month < 1 || month > 12) { throw new StorageException("Date month out of range 1-12: " + month); } if (day < 1 || day > 31) { throw new StorageException("Date day out of range 1-31: " + day); } return Integer.parseInt(string); }</code><technical_language>a date parser for this. find problems parse date February 30th</technical_language>

Target:
private int validate (String string) { LocalDate date = null; try { date = LocalDate.parse(string, gtfsDateFormat); } catch (DateTimeParseException ex) { throw new StorageException(NewGTFSErrorType.DATE_FORMAT, string); } int year = date.getYear(); if (year < 2000 || year > 2100) { throw new StorageException(NewGTFSErrorType.DATE_RANGE, string); } return Integer.parseInt(string); }
Source:
<code>private void moveScreen(Direction direction) { FormController formController = getFormController(); if (formController == null) { Timber.w("FormController has a null value"); swipeHandler.setBeenSwiped(false); return; } if (audioRecorderViewModel.isRecording().getValue()) { DialogUtils.showIfNotShowing(RecordingWarningDialogFragment.class, getSupportFragmentManager()); swipeHandler.setBeenSwiped(false); return; } if (direction == FORWARDS && formController.getEvent() == FormEntryController.EVENT_END_OF_FORM) { swipeHandler.setBeenSwiped(false); return; } else if (direction == BACKWARDS && !allowMovingBackwards) { swipeHandler.setBeenSwiped(false); return; } <START> state = null; END> switch (direction) { case FORWARDS: if (!saveBeforeNextView(formController)) { formEntryViewModel.moveForward(); formIndexAnimationHandler.handle(formController.getFormIndex()); } break; case BACKWARDS: if (formController.currentPromptIsQuestion()) { saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); } formEntryViewModel.moveBackward(); formIndexAnimationHandler.handle(formController.getFormIndex()); break; } }</code><technical_language>track of questions' guidance hints expanded search text for selects search appearance. great move a view model, I think</technical_language>

Target:
private boolean moveScreen(Direction direction) { FormController formController = getFormController(); if (formController == null) { Timber.w("FormController has a null value"); return false; } if (audioRecorderViewModel.isRecording().getValue()) { DialogUtils.showIfNotShowing(RecordingWarningDialogFragment.class, getSupportFragmentManager()); return false; } if (direction == FORWARDS) { if (formController.getEvent() == FormEntryController.EVENT_END_OF_FORM) { return false; } if (!saveBeforeNextView(formController)) { formEntryViewModel.moveForward(); formIndexAnimationHandler.handle(formController.getFormIndex()); return true; } else { return false; } } else { if (formController.isCurrentQuestionFirstInForm() || !allowMovingBackwards) { return false; } if (formController.currentPromptIsQuestion()) { saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); } formEntryViewModel.moveBackward(); formIndexAnimationHandler.handle(formController.getFormIndex()); return true; } }
Source:
<code>public void createOrReplaceOrder(Order order) throws OrderServiceFailureException, NetworkFailureException { <START> this.throwRandomError(); if (order.getId() == null) { Order newOrder = new Order(); newOrder.setId(UUID.randomUUID().toString()); newOrder.setContent(order.getContent()); logger.info(String.format("Order created: %s", newOrder)); } else { logger.info(String.format("Order updated %s", order)); } this.throwRandomError(); <END> }</code><technical_language>sync operations call async operation block()</technical_language>

Target:
public void createOrReplaceOrder(Order order) throws OrderServiceFailureException, NetworkFailureException { this.throwRandomError(); try { TimeUnit.MICROSECONDS.sleep(50); } catch (InterruptedException e) { throw new RuntimeException(e); } if (order.getId() == null) { Order newOrder = new Order(); newOrder.setId(UUID.randomUUID().toString()); newOrder.setContent(order.getContent()); logger.info(String.format("Order created: %s", newOrder)); } else { logger.info(String.format("Order updated %s", order)); } this.throwRandomError(); }
Source:
<code>public static NonNullList<Fluid> getFluids(String name) { NonNullList<Fluid> ret = NonNullList.<Fluid>create(); <START> if (NAME_TO_FLUIDS.containsKey(name = name.toLowerCase())) <END> { ret.addAll(NAME_TO_FLUIDS.get(name)); } return ret; }</code><technical_language>assign variables line else, if doing. bad style</technical_language>

Target:
public static NonNullList<Fluid> getFluids(String name) { NonNullList<Fluid> ret = NonNullList.<Fluid>create(); if (nameExists(name)) { ret.addAll(NAME_TO_FLUIDS.get(name.toLowerCase(Locale.ENGLISH))); } return ret; }
Source:
<code>public void testGlobalFunctionNameInBooleanExpressionDepth2() { test("var a = {b: function(){}}; a.b.c = 1; if (a.b) x(a.b.c);", "var a$b = function(){}; var a$b$c = 1; if (a$b) x(a$b$c);"); test("var a = { b: function(){}}; a.b.c = 1; " + "if (a.b) x(a.b.c);", <START> "var a = {b: function(){}}; var a$b$c = 1; if (a.b) x(a$b$c);"); <END> test("var a = {b: function(){}}; a.b.c = 1; " + "if (a.b) x(a.b.c);", "var a$b = function(){}; a$b.c = 1; if (a$b) x(a$b.c);"); }</code><technical_language>If collapse a.b, a.b$c (or a.b.c) in this example, a$b$c</technical_language>

Target:
public void testGlobalFunctionNameInBooleanExpressionDepth2() { test("var a = {b: function(){}}; a.b.c = 1; if (a.b) x(a.b.c);", "var a$b = function(){}; var a$b$c = 1; if (a$b) x(a$b$c);"); testSame("var a = { b: function(){}}; a.b.c = 1; " + "if (a.b) x(a.b.c);"); test("var a = {b: function(){}}; a.b.c = 1; " + "if (a.b) x(a.b.c);", "var a$b = function(){}; a$b.c = 1; if (a$b) x(a$b.c);"); }
Source:
<code>public void testMoreOptionsAllItemsExist() { onTopBarView() .performOpenMoreOptions(); onOptionsMenu() .checkItemExists(R.string.menu_load_image) .checkItemExists(R.string.menu_hide_menu) .checkItemExists(R.string.help_title) .checkItemExists(R.string.pocketpaint_menu_about) <START> <END> .checkItemDoesNotExist(R.string.menu_save_image) .checkItemDoesNotExist(R.string.menu_save_copy) .checkItemDoesNotExist(R.string.menu_new_image) .checkItemExists(R.string.menu_discard_image) .checkItemExists(R.string.menu_export); }</code><technical_language>checkItemDoesNotExist instead of removing</technical_language>

Target:
public void testMoreOptionsAllItemsExist() { onTopBarView() .performOpenMoreOptions(); onOptionsMenu() .checkItemExists(R.string.menu_load_image) .checkItemExists(R.string.menu_hide_menu) .checkItemExists(R.string.help_title) .checkItemExists(R.string.pocketpaint_menu_about) .checkItemDoesNotExist(R.string.menu_save_image) .checkItemDoesNotExist(R.string.menu_save_copy) .checkItemDoesNotExist(R.string.menu_new_image) .checkItemDoesNotExist(R.string.menu_rate_us) .checkItemExists(R.string.menu_discard_image) .checkItemExists(R.string.menu_export); }
Source:
<code>public IdentityLinkedHashMap<Expression, Type> getCoercions() { <START> return NodeRefCollections.toIdentityMap(coercions); <END> }</code><technical_language>ditto: consider unmodifiable view</technical_language>

Target:
public Map<NodeRef<Expression>, Type> getCoercions() { return unmodifiableMap(coercions); }
Source:
<code>public RuntimeInstance get() { String rl = "resource.loader"; String pkg = "org.apache.velocity.runtime.resource.loader"; Properties p = new Properties(); <START> p.setProperty(RuntimeConstants.VM_PERM_INLINE_LOCAL, "false"); <END> p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Slf4jLogChute.class.getName()); p.setProperty("runtime.log.logsystem.log4j.category", "velocity"); if (site.mail_dir.isDirectory()) { p.setProperty(rl, "file, class"); p.setProperty("file." + rl + ".class", pkg + ".FileResourceLoader"); p.setProperty("file." + rl + ".path", site.mail_dir.getAbsolutePath()); p.setProperty("class." + rl + ".class", pkg + ".ClasspathResourceLoader"); } else { p.setProperty(rl, "class"); p.setProperty("class." + rl + ".class", pkg + ".ClasspathResourceLoader"); } RuntimeInstance ri = new RuntimeInstance(); try { ri.init(p); } catch (Exception err) { throw new ProvisionException("Cannot configure Velocity templates", err); } return ri; }</code><technical_language>I thought wanted this true</technical_language>

Target:
public RuntimeInstance get() { String rl = "resource.loader"; String pkg = "org.apache.velocity.runtime.resource.loader"; Properties p = new Properties(); p.setProperty(RuntimeConstants.VM_PERM_INLINE_LOCAL, "true"); p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Slf4jLogChute.class.getName()); p.setProperty("runtime.log.logsystem.log4j.category", "velocity"); if (site.mail_dir.isDirectory()) { p.setProperty(rl, "file, class"); p.setProperty("file." + rl + ".class", pkg + ".FileResourceLoader"); p.setProperty("file." + rl + ".path", site.mail_dir.getAbsolutePath()); p.setProperty("class." + rl + ".class", pkg + ".ClasspathResourceLoader"); } else { p.setProperty(rl, "class"); p.setProperty("class." + rl + ".class", pkg + ".ClasspathResourceLoader"); } RuntimeInstance ri = new RuntimeInstance(); try { ri.init(p); } catch (Exception err) { throw new ProvisionException("Cannot configure Velocity templates", err); } return ri; }
Source:
<code>public AmazonServiceException handle(HttpResponse errorResponse) throws Exception { Document document; try { document = XpathUtils.documentFrom(errorResponse.getContent()); } catch (SAXParseException e) { AmazonServiceException exception = new AmazonServiceException(String.format("Unable to unmarshall error response (%s)", e.getMessage()), e); exception.setErrorCode(String.format("%s (%s)", errorResponse.getStatusText(), errorResponse.getStatusCode())); exception.setErrorType(AmazonServiceException.ErrorType.Unknown); <START> exception.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); <END> return exception; } for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) { AmazonServiceException ase = unmarshaller.unmarshall(document); if (ase != null) { ase.setStatusCode(errorResponse.getStatusCode()); return ase; } } throw new AmazonClientException("Unable to unmarshall error response from service"); }</code><technical_language>errorResponse.getStatusCode() for setStatusCode reporting right status code, in case a 500 this triggered</technical_language>

Target:
public AmazonServiceException handle(HttpResponse errorResponse) throws Exception { Document document; try { document = XpathUtils.documentFrom(errorResponse.getContent()); } catch (SAXParseException e) { AmazonServiceException exception = new AmazonServiceException(String.format("Unable to unmarshall error response (%s)", e.getMessage()), e); exception.setErrorCode(String.format("%s %s", errorResponse.getStatusCode(), errorResponse.getStatusText())); exception.setErrorType(AmazonServiceException.ErrorType.Service); return exception; } for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) { AmazonServiceException ase = unmarshaller.unmarshall(document); if (ase != null) { ase.setStatusCode(errorResponse.getStatusCode()); return ase; } } throw new AmazonClientException("Unable to unmarshall error response from service"); }