auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void start(ComponentContext context) { super.start(context); if (Framework.isBooleanPropertyTrue(CLUSTERING_ENABLED_PROP)) { String nodeId = Framework.getProperty(NODE_ID_PROP); if (StringUtils.isBlank(nodeId)) { nodeId = String.valueOf(RANDOM.nextLong()); log.warn("Missing cluster node id configuration, please define it explicitly " + "(usually through repository.clustering.id). Using random cluster node id instead: " + nodeId); } else { nodeId = nodeId.trim(); } invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); }

Target:
public void start(ComponentContext context) { super.start(context); if (Framework.isBooleanPropertyTrue(CLUSTERING_ENABLED_PROP)) { String nodeId = Framework.getProperty(NODE_ID_PROP); if (StringUtils.isBlank(nodeId)) { nodeId = String.valueOf(RANDOM.nextLong()); log.warn("Missing cluster node id configuration, please define it explicitly " + "(usually through repository.clustering.id). Using random cluster node id instead: {}", nodeId); } else { nodeId = nodeId.trim(); } invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); }
Source:
private JoinNode.EquiJoinClause equiJoinClause(Symbol symbol1, Symbol symbol2) { return new JoinNode.EquiJoinClause(symbol1, symbol2); }

Target:
private EquiJoinClause equiJoinClause(Symbol symbol1, Symbol symbol2) { return new EquiJoinClause(symbol1, symbol2); }
Source:
private IBinding resolveBindingPromiscuous() { if (fBinding != null && !(fBinding instanceof IProblemBinding)) { return fBinding; } setBinding(null); IBinding result = resolveBindingNormal(); if (!(result instanceof IProblemBinding)) { setBinding(null); } return result; }

Target:
private IBinding resolveBindingPromiscuous() { if (fBinding == null) { try { CPPSemantics.disablePromiscuousBindingResolution(); resolveBindingNormal(); } finally { CPPSemantics.enablePromiscuousBindingResolution(); } } if (!(fBinding instanceof ProblemBinding)) { return fBinding; } ProblemBinding problem = (ProblemBinding) fBinding; if (problem.getPromiscuousBinding() == null) { IBinding promiscuous = resolveBindingNormal(); problem.setPromiscuousBinding(promiscuous); fBinding = problem; } return problem.getPromiscuousBinding(); }
Source:
public static String normalizeSpace(final String str) { if (isEmpty(str)) { return str; } if (isBlank(str)){ return EMPTY; } final int size = str.length(); final char[] newChars = new char[size]; int count = 0; int whitespacesCount = 0; for (int i = 0; i < size; i++) { char actualChar = str.charAt(i); boolean isWhitespace = Character.isWhitespace(actualChar) || actualChar == '\u00A0'; if (!isWhitespace) { newChars[count++] = actualChar; whitespacesCount = 0; } else { if (whitespacesCount == 0) { newChars[count++] = SPACE.charAt(0); } whitespacesCount++; } } return new String(newChars, 0, count).trim(); }

Target:
public static String normalizeSpace(final String str) { if (isEmpty(str)) { return str; } final int size = str.length(); final char[] newChars = new char[size]; int count = 0; int whitespacesCount = 0; boolean startWhitespaces = true; for (int i = 0; i < size; i++) { char actualChar = str.charAt(i); boolean isWhitespace = Character.isWhitespace(actualChar); if (!isWhitespace) { startWhitespaces = false; newChars[count++] = (actualChar == 160 ? 32 : actualChar); whitespacesCount = 0; } else { if (whitespacesCount == 0 && !startWhitespaces) { newChars[count++] = SPACE.charAt(0); } whitespacesCount++; } } if (startWhitespaces) { return EMPTY; } return new String(newChars, 0, count - (whitespacesCount > 0 ? 1 : 0)).trim(); }
Source:
public AnalysisCache getAnalysisCache() { if (analysisCache == null || isIgnoreIncrementalAnalysis() && isAnalysisCacheFunctional()) { setAnalysisCache(null); } return analysisCache; }

Target:
public AnalysisCache getAnalysisCache() { if (analysisCache == null || isIgnoreIncrementalAnalysis() && !(analysisCache instanceof NoopAnalysisCache)) { setAnalysisCache(new NoopAnalysisCache()); } return analysisCache; }
Source:
MnsService(MapClientService context) { if (VDBG) { Log.v(TAG, "MnsService()"); } sContext = context; sAcceptThread = new SocketAcceptor(); sServerSockets = ObexServerSockets.create(sAcceptThread); if (sServerSockets == null) { Log.e(TAG, "ObexServerSockets is null"); return; } SdpManager sdpManager = SdpManager.getDefaultManager(); if (sdpManager == null) { Log.e(TAG, "SdpManager is null"); return; } mSdpHandle = sdpManager.createMapMnsRecord("MAP Message Notification Service", sServerSockets.getRfcommChannel(), -1, MNS_VERSION, MasClient.MAP_SUPPORTED_FEATURES); }

Target:
MnsService(MapClientService context) { if (VDBG) { Log.v(TAG, "MnsService()"); } sContext = context; sAcceptThread = new SocketAcceptor(); sServerSockets = Objects.requireNonNull(ObexServerSockets.create(sAcceptThread), "Cannot create OBEX server socket for MAP profile"); SdpManager sdpManager = SdpManager.getDefaultManager(); if (sdpManager == null) { Log.e(TAG, "SdpManager is null"); return; } mSdpHandle = sdpManager.createMapMnsRecord("MAP Message Notification Service", sServerSockets.getRfcommChannel(), -1, MNS_VERSION, MasClient.MAP_SUPPORTED_FEATURES); }
Source:
public Future<Boolean> addBagItem() { FutureTask<Boolean> future = new FutureTask<>(new Runnable() { @Override public void run() { long sleepBackoff = 200L; final int minimumIdle = config.getMinimumIdle(); final int maxPoolSize = config.getMaximumPoolSize(); while (poolState == POOL_NORMAL && totalConnections.get() < maxPoolSize && getIdleConnections() <= minimumIdle && !addConnection()) { quietlySleep(sleepBackoff); sleepBackoff = Math.min((long) (connectionTimeout / 2), (long) (sleepBackoff * 1.5)); } } }, true); addConnectionExecutor.execute(future); return future; }

Target:
public Future<Boolean> addBagItem() { FutureTask<Boolean> future = new FutureTask<>(new Runnable() { @Override public void run() { long sleepBackoff = 200L; final int minimumIdle = config.getMinimumIdle(); final int maxPoolSize = config.getMaximumPoolSize(); while (poolState == POOL_NORMAL && totalConnections.get() < maxPoolSize && getIdleConnections() <= minimumIdle && !addConnection()) { quietlySleep(sleepBackoff); sleepBackoff = Math.min(connectionTimeout / 2, (long) (sleepBackoff * 1.5)); } } }, true); addConnectionExecutor.execute(future); return future; }
Source:
private List<GenericArtifact> readArtifactList(ObjectMapper mapper, String hydratedTemplate) { try { return mapper.readValue(hydratedTemplate, artifactListReference); } catch (IOException ioe) { log.error(ioe.getMessage()); return null; } }

Target:
private List<GenericArtifact> readArtifactList(ObjectMapper mapper, String hydratedTemplate) { try { return mapper.readValue(hydratedTemplate, artifactListReference); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
Source:
public MojoParameter getContainer(String[] path) { if(path == null || path.length == 0) return this; MojoParameter param = this; int i = 0; while(param != null && i < path.length) { param = param.getNestedParameter(path[i]); i++ ; } if(param == null) return null; return param; }

Target:
public MojoParameter getContainer(String[] path) { if(path == null || path.length == 0) { return this; } MojoParameter param = this; int i = 0; while(param != null && i < path.length) { param = param.getNestedParameter(path[i]); i++ ; } if(param == null) { return null; } return param; }
Source:
public void testPutsSucceedWhileTopologyChanges() throws Exception { RemoteCache<Integer, String> remote = client(0).getCache(); remote.put(1, "v1"); assertEquals("v1", remote.get(1)); PutHammer putHammer = new PutHammer(); Future<Void> putHammerFuture = fork(putHammer); EmbeddedCacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(getCacheConfiguration()); registerCacheManager(cm); HotRodServer newServer = HotRodClientTestingUtil.startHotRodServer(cm); waitForClusterToForm(); TestingUtil.waitForRehashToComplete(cm.getCache(), cache(0)); TestingUtil.sleepThread(2000); HotRodClientTestingUtil.killServers(newServer); TestingUtil.killCacheManagers(cm); TestingUtil.waitForRehashToComplete(cache(0)); remote.put(-1, "minus one"); RoundRobinBalancingStrategy strategy = getLoadBalancer(client(0)); SocketAddress[] servers = strategy.getServers(); putHammer.stop = true; putHammerFuture.get(); assertEquals(1, servers.length); }

Target:
public void testPutsSucceedWhileTopologyChanges() throws Exception { RemoteCache<Integer, String> remote = client(0).getCache(); remote.put(1, "v1"); assertEquals("v1", remote.get(1)); PutHammer putHammer = new PutHammer(); Future<Void> putHammerFuture = fork(putHammer); HotRodServer newServer = addHotRodServer(getCacheConfiguration()); TestingUtil.sleepThread(2000); HotRodClientTestingUtil.killServers(newServer); TestingUtil.killCacheManagers(newServer.getCacheManager()); TestingUtil.waitForRehashToComplete(cache(0)); remote.put(-1, "minus one"); RoundRobinBalancingStrategy strategy = getLoadBalancer(client(0)); SocketAddress[] servers = strategy.getServers(); putHammer.stop = true; putHammerFuture.get(); assertEquals(1, servers.length); }
Source:
public static Schema getSchema(RuntimeContainer container, SalesforceProvideConnectionProperties properties, String module) throws IOException { SalesforceSourceOrSink ss = new SalesforceSourceOrSink(); ss.initialize(null, (ComponentProperties) properties); PartnerConnection connection = null; try { connection = ss.connect(container).connection; } catch (IOException ex) { throw new ComponentException(SalesforceRuntimeCommon.exceptionToValidationResult(ex)); } return ss.getSchema(connection, module); }

Target:
public static Schema getSchema(RuntimeContainer container, SalesforceProvideConnectionProperties properties, String module) throws IOException { ClassLoader classLoader = SalesforceSourceOrSink.class.getClassLoader(); RuntimeInfo runtimeInfo = SalesforceDefinition.getCommonRuntimeInfo(SalesforceSourceOrSink.class.getCanonicalName()); try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClassWithCurrentJVMProperties(runtimeInfo, classLoader)) { SalesforceSourceOrSink ss = (SalesforceSourceOrSink) sandboxedInstance.getInstance(); ss.initialize(null, (ComponentProperties) properties); PartnerConnection connection = null; try { connection = ss.connect(container).connection; } catch (IOException ex) { throw new ComponentException(SalesforceRuntimeCommon.exceptionToValidationResult(ex)); } return ss.getSchema(connection, module); } }
Source:
public String toString() { return toStringHelper(this) .add("queryId", queryId) .add("transactionId", transactionId) .add("user", getUser()) .add("principal", getIdentity().getPrincipal().orElse(null)) .add("source", source.orElse(null)) .add("catalog", catalog.orElse(null)) .add("schema", schema.orElse(null)) .add("timeZoneKey", timeZoneKey) .add("locale", locale) .add("remoteUserAddress", remoteUserAddress.orElse(null)) .add("userAgent", userAgent.orElse(null)) .add("clientInfo", clientInfo.orElse(null)) .add("tags", Joiner.on(',').join(tags)) .add("startTime", startTime) .omitNullValues() .toString(); }

Target:
public String toString() { return toStringHelper(this) .add("queryId", queryId) .add("transactionId", transactionId) .add("user", getUser()) .add("principal", getIdentity().getPrincipal().orElse(null)) .add("source", source.orElse(null)) .add("catalog", catalog.orElse(null)) .add("schema", schema.orElse(null)) .add("timeZoneKey", timeZoneKey) .add("locale", locale) .add("remoteUserAddress", remoteUserAddress.orElse(null)) .add("userAgent", userAgent.orElse(null)) .add("clientInfo", clientInfo.orElse(null)) .add("clientTags", clientTags) .add("startTime", startTime) .omitNullValues() .toString(); }
Source:
protected void run() throws Exception { walk = createWalk(); for (final RevSort s : sorting) walk.sort(s, true); if (pathFilter instanceof FollowFilter) walk.setTreeFilter(pathFilter); else if (pathFilter != TreeFilter.ALL) walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) for (Ref a : db.getAllRefs().values()) { ObjectId oid = a.getPeeledObjectId(); commits.add(walk.parseCommit((oid == null) ? a.getObjectId() : oid)); } if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); else walk.markStart(real); } final long start = System.currentTimeMillis(); final int n = walkLoop(); if (count) { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); System.err.println(MessageFormat.format( CLIText.get().timeInMilliSeconds, end - start)); } }

Target:
protected void run() throws Exception { walk = createWalk(); for (final RevSort s : sorting) walk.sort(s, true); if (pathFilter instanceof FollowFilter) walk.setTreeFilter(pathFilter); else if (pathFilter != TreeFilter.ALL) walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) for (Ref a : db.getAllRefs().values()) { ObjectId oid = a.getPeeledObjectId(); if (oid == null) oid = a.getObjectId(); try { commits.add(walk.parseCommit(oid)); } catch (IncorrectObjectTypeException e) { } } if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); else walk.markStart(real); } final long start = System.currentTimeMillis(); final int n = walkLoop(); if (count) { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); System.err.println(MessageFormat.format( CLIText.get().timeInMilliSeconds, end - start)); } }
Source:
public String getUrlName() { return "webhook"; }

Target:
public String getUrlName() { String url = globalConfig.getSlackOutgoingWebhookURL(); if (url == null || url.equals("")) return null; return "/"+url; }
Source:
private String getEncodingCharsetName(byte[] codedCharacterSet){ String codedCharacterSetString = new String(codedCharacterSet); try { if (Charset.isSupported(codedCharacterSetString)) { return codedCharacterSetString; } }catch (IllegalCharsetNameException e){ }catch (IllegalArgumentException e){ } byte[] codedCharacterSetNormalized = new byte[codedCharacterSet.length]; int j=0; for(int i=0; i< codedCharacterSet.length; i++){ if(codedCharacterSet[i] != ' ') { codedCharacterSetNormalized[j++] = codedCharacterSet[i]; } } for(CharsetEscapeSequence escapeSeq : CharsetEscapeSequence.getSupportedEscapeSeqList()){ if(j != escapeSeq.escapeSequence.length) continue; boolean match = true; for(int i=0; i < j; i++ ){ if(codedCharacterSetNormalized[i] != escapeSeq.escapeSequence[i]){ match = false; break; } } if(match){ return escapeSeq.charsetName; } } return "ISO-8859-1"; }

Target:
private String getEncodingCharsetName(byte[] codedCharacterSet){ final Character WHITESPACE = ' '; String codedCharacterSetString = new String(codedCharacterSet); try { if (Charset.isSupported(codedCharacterSetString)) { return codedCharacterSetString; } }catch (IllegalCharsetNameException e){ }catch (IllegalArgumentException e){ } byte[] utf8EscSeq = new byte[]{'\u001B','%','G'}; int j=0; boolean match = true; for(byte character : codedCharacterSet){ if(!WHITESPACE.equals(character) && utf8EscSeq[j++] != character) { match = false; } } if(match){ return UTF_8; } return DEFAULT_ENCODING; }
Source:
public PagingStore getPageStore(final SimpleString storeName) throws Exception { if (managementAddress != null && storeName.startsWith(managementAddress)) { return null; } try { return stores.computeIfAbsent(storeName, (s) -> { try { return newStore(s); } catch (Exception e) { throw new RuntimeException(e); } }); } catch (RuntimeException e) { throw (Exception) e.getCause(); } }

Target:
public PagingStore getPageStore(final SimpleString storeName) throws Exception { if (managementAddress != null && storeName.startsWith(managementAddress)) { return null; } PagingStore store = stores.get(storeName); if (store != null) { return store; } try { return stores.computeIfAbsent(storeName, (s) -> { try { return newStore(s); } catch (Exception e) { throw new RuntimeException(e); } }); } catch (RuntimeException e) { throw (Exception) e.getCause(); } }
Source:
public void removeAllGroupResourceAttributes(PerunSession sess, Resource resource) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { List<Group> groups = this.perunBl.getResourcesManagerBl().getAssignedGroups(sess, resource); List<Attribute> attrs = new ArrayList<>(); for(Group group: groups){ attrs =this.getAttributes(sess, resource, group); for(Attribute attr : attrs) { attr.setValue(null); try { this.checkAttributesValue(sess, resource, group, attrs); } catch(WrongAttributeAssignmentException ex) { throw new ConsistencyErrorException(ex); } } } this.attributesManagerImpl.removeAllGroupResourceAttributes(sess, resource); log.info("All non-virtual group-resource attributes removed for all groups and {}", resource); }

Target:
public void removeAllGroupResourceAttributes(PerunSession sess, Resource resource) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { List<Group> groups = this.perunBl.getResourcesManagerBl().getAssignedGroups(sess, resource); List<Attribute> attrs = new ArrayList<>(); for (Group group : groups) { this.getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, resource, group); } this.attributesManagerImpl.removeAllGroupResourceAttributes(sess, resource); log.info("All non-virtual group-resource attributes removed for all groups and {}", resource); }
Source:
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { return client.get(sessionProperties.createHeaderFromSession(session)).listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }

Target:
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { return client.get(sessionProperties.toHeader(session)) .listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
Source:
private void addAccount(String data) throws JSONException { JSONObject auth = new JSONObject(data); OAuth2AuthzSession session = new OAuth2AuthzSession(); session.setAccountId(AuthData.NAME); session.setAccessToken(auth.getString("key") + ":" + auth.getString("secret")); sessionStore.save(session); }

Target:
private void addAccount(String data) throws JSONException { JSONObject auth = new JSONObject(data); Session session = new Session(); session.setAccountId(AuthData.NAME); session.setKey(auth.getString(AuthData.Credentials.KEY)); session.setSecret(auth.getString(AuthData.Credentials.SECRET)); if (auth.has(AuthData.Credentials.EXPIRES_ON)) { session.setExpires_on(Long.parseLong(auth.getString(AuthData.Credentials.EXPIRES_ON))); } else { session.setExpires_on(0); } sessionStore.save(session); }
Source:
public void hashCodeForCompositeConvertersChangesWithDifferentTransformationChain() { Converter byteArrayToObjectConverter = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter = new ByteArrayToInputStream(); Converter byteArrayToObjectConverter2 = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter2 = new ByteArrayToInputStream(); Converter byteArrayToSerializableConverter = new ByteArrayToSerializable(); int hashCodeConverterA = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAClone = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAFakeClone = new CompositeConverter(byteArrayToObjectConverter2, byteArrayToInputStreamConverter2).hashCode(); int hashCodeConverterReverseClone = new CompositeConverter(byteArrayToInputStreamConverter, byteArrayToObjectConverter).hashCode(); int hashCodeConverterNotAClone = new CompositeConverter(byteArrayToInputStreamConverter, byteArrayToSerializableConverter).hashCode(); assertThat(Arrays.asList(hashCodeConverterAClone), everyItem(equalTo(hashCodeConverterA))); assertThat(Arrays.asList(hashCodeConverterReverseClone, hashCodeConverterNotAClone, hashCodeConverterAFakeClone), everyItem(not(equalTo(hashCodeConverterA)))); }

Target:
public void hashCodeForCompositeConvertersChangesWithDifferentTransformationChain() { Converter byteArrayToObjectConverter = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter = new ByteArrayToInputStream(); Converter byteArrayToObjectConverter2 = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter2 = new ByteArrayToInputStream(); int hashCodeConverterA = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAClone = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAnotherClone = new CompositeConverter(byteArrayToObjectConverter2, byteArrayToInputStreamConverter2).hashCode(); assertThat(Arrays.asList(hashCodeConverterAClone, hashCodeConverterAnotherClone), everyItem(equalTo(hashCodeConverterA))); }
Source:
@Override public String toString() { return createdSince == null ? "" : "created:>=" + ISO_8601_DATE.print(createdSince); }

Target:
@Override public String toString() { return createdSince == null ? null : "created:>=" + ISO_8601_DATE.print(createdSince); }
Source:
protected void configure() { bind(TestAuthServiceClient.class).to(KeycloakTestAuthServiceClient.class); bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class); bind(TestWorkspaceServiceClient.class).to(CheTestWorkspaceServiceClient.class); bind(DefaultTestUserProvider.class).to(MultiUserCheDefaultTestUserProvider.class); bind(TestUser.class).toProvider(TestUserProvider.class); bind(TestUserProvider.class).to(MultiUserCheTestUserProvider.class); bind(AdminTestUser.class).toProvider(AdminTestUserProvider.class); bind(AdminTestUserProvider.class).to(MultiUserCheAdminTestUserProvider.class); bind(TestOrganizationServiceClient.class).to(CheTestDefaultOrganizationServiceClient.class); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<AdminTestUser>>() {}.getType()))); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<TestUserImpl>>() {}.getType()))); install(new FactoryModuleBuilder().build(TestOrganizationServiceClientFactory.class)); }

Target:
protected void configure() { bind(TestAuthServiceClient.class).to(KeycloakTestAuthServiceClient.class); bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class); bind(DefaultTestUserProvider.class).to(MultiUserCheDefaultTestUserProvider.class); bind(TestUser.class).toProvider(TestUserProvider.class); bind(TestUserProvider.class).to(MultiUserCheTestUserProvider.class); bind(AdminTestUser.class).toProvider(AdminTestUserProvider.class); bind(AdminTestUserProvider.class).to(MultiUserCheAdminTestUserProvider.class); bind(TestOrganizationServiceClient.class).to(CheTestDefaultOrganizationServiceClient.class); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<AdminTestUser>>() {}.getType()))); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<TestUserImpl>>() {}.getType()))); install(new FactoryModuleBuilder().build(TestOrganizationServiceClientFactory.class)); }
Source:
public Map<K, V> getEntries() { Set<Node> nodes = new HashSet<>(this.group.getMembership().getMembers()); try (Batch batch = this.batcher.createBatch()) { Map<K, V> map = new HashMap<>(); for (Map.Entry<K, V> kvEntry : this.cache.getAdvancedCache().getAll(nodes).values()) { if (map.put(kvEntry.getKey(), kvEntry.getValue()) != null) { throw new IllegalStateException("Duplicate key"); } } return map; } }

Target:
public Map<K, V> getEntries() { Set<Node> nodes = new HashSet<>(this.group.getMembership().getMembers()); try (Batch batch = this.batcher.createBatch()) { Map<K, V> map = new HashMap<>(); for (Map.Entry<K, V> entry : this.cache.getAdvancedCache().getAll(nodes).values()) { map.put(entry.getKey(), entry.getValue()); } return map; } }
Source:
public void setupHttpService() { service = NettyHttpService.builder() .setHost("localhost") .setPort(7777) .addHttpHandlers(ImmutableList.of(new PingHandler())) .build(); service.startAndWait(); UrlFetchRealtimeSourceConfig config = new UrlFetchRealtimeSourceConfig( String.format("http://%s:%s/ping", service.getBindAddress().getHostName(), service.getBindAddress().getPort()), 1L ); }

Target:
public void setupHttpService() { service = NettyHttpService.builder() .setHost("localhost") .setPort(7777) .addHttpHandlers(ImmutableList.of(new PingHandler())) .build(); service.startAndWait(); }
Source:
private Query fieldQuery(IndexPredicate<ChangeData> p) throws QueryParseException { if (p instanceof RegexFilePredicate) { return regexQuery(p); } else if (p.getType() == FieldType.INTEGER) { return intQuery(p); } else if (p.getType() == FieldType.EXACT) { return exactQuery(p); } else { throw badFieldType(p.getType()); } }

Target:
private Query fieldQuery(IndexPredicate<ChangeData> p) throws QueryParseException { if (p.getType() == FieldType.INTEGER) { return intQuery(p); } else if (p.getType() == FieldType.TIMESTAMP) { return timestampQuery(p); } else if (p.getType() == FieldType.EXACT) { return exactQuery(p); } else { throw badFieldType(p.getType()); } }
Source:
public static void main(String[] arg) { if (arg.length > 0 && arg[0].startsWith("testCloseConsumerOnConnectionReset")) { try { AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:5672?transport.soLinger=0"), null, null); AmqpConnection connection = client.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(QUEUE_NAME); receiver.flow(10); System.exit(OK); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } } else { System.err.println("Test " + arg[0] + " unkown"); System.exit(-2); } }

Target:
public static void main(String[] arg) { if (arg.length == 2 && arg[0].startsWith("testCloseConsumerOnConnectionReset")) { try { String queueName = arg[1]; AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:5672?transport.soLinger=0"), null, null); AmqpConnection connection = client.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(queueName); receiver.flow(10); System.exit(OK); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } } else { System.err.println("Test " + arg[0] + " unkown"); System.exit(-2); } }
Source:
public void markAsDispatchedToDeliver(UUID channelID) { ChannelInformation channelInformation = channelDeliveryInfo.get(channelID); channelInformation.addChannelStatus(ChannelMessageStatus.DISPATCHED); if (!this.isBeyondLastRollbackedMessage) { int i = channelInformation.incrementDeliveryCount(); MessageTracer.trace(getMessageID(), getDestination(), "Message within rollback id. " + "Increased count " + i); } else { MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK); MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK + " current count = " + channelInformation.getDeliveryCount()); } }

Target:
public void markAsDispatchedToDeliver(UUID channelID) { ChannelInformation channelInformation = channelDeliveryInfo.get(channelID); channelInformation.addChannelStatus(ChannelMessageStatus.DISPATCHED); if (!this.isBeyondLastRollbackedMessage) { int i = channelInformation.incrementDeliveryCount(); MessageTracer.trace(getMessageID(), getDestination(), "Message within rollback id. " + "Current count " + i); } else { MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK); MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK + " current count = " + channelInformation.getDeliveryCount()); } }
Source:
public Optional<Course> getCurrentCourse(Path path) { String[] folders = path.toString().split("\\" + File.separator); for (String folder : folders) { if (courseStubs.containsKey(folder)) { return Optional.of(courseStubs.get(folder)); } } return Optional.absent(); }

Target:
public Optional<Course> getCurrentCourse(Path path) { Iterator<Path> it = path.iterator(); while (it.hasNext()) { String folder = it.next().toString(); if (courseStubs.containsKey(folder)) { return Optional.of(courseStubs.get(folder)); } } return Optional.absent(); }
Source:
public final void testGetSourceDateFrom() { Calendar one = Calendar.getInstance(); Calendar other = Calendar.getInstance(); one.set(2009, 01, 01, 0, 0, 0); one.set(Calendar.MILLISECOND, 0); other.set(2009, 03, 31, 0, 0, 0); other.set(Calendar.MILLISECOND, 0); assertEquals(one.getTime(), testManager.getSourceDateFrom()); assertNotSame(other.getTime(), testManager.getSourceDateFrom()); }

Target:
public final void testGetSourceDateFrom() { Calendar calendarOne = Calendar.getInstance(); Calendar calendarTwo = Calendar.getInstance(); calendarOne.set(2009, 01, 01, 0, 0, 0); calendarOne.set(Calendar.MILLISECOND, 0); calendarTwo.set(2009, 03, 31, 0, 0, 0); calendarTwo.set(Calendar.MILLISECOND, 0); assertEquals(calendarOne.getTime(), testManager.getSourceDateFrom()); assertNotSame(calendarTwo.getTime(), testManager.getSourceDateFrom()); }
Source:
public ImmutableBitmap union(Iterable<ImmutableBitmap> b) throws ClassCastException { if (b instanceof List) { final List<ImmutableBitmap> bitmapList = (List<ImmutableBitmap>) b; if (bitmapList.isEmpty()) { return makeEmptyImmutableBitmap(); } else if (bitmapList.size() == 1) { return Iterables.getOnlyElement(b); } } return new WrappedImmutableConciseBitmap(ImmutableConciseSet.union(unwrap(b))); }

Target:
public ImmutableBitmap union(Iterable<ImmutableBitmap> b) throws ClassCastException { if (b instanceof Collection) { final Collection<ImmutableBitmap> bitmapList = (Collection<ImmutableBitmap>) b; final int size = bitmapList.size(); if (size == 0) { return makeEmptyImmutableBitmap(); } else if (size == 1) { return Iterables.getOnlyElement(b); } } return new WrappedImmutableConciseBitmap(ImmutableConciseSet.union(unwrap(b))); }
Source:
protected ClientConfig createClientConfig() { ClientConfig cc = new ClientConfig(m_username, m_password); cc.setProcedureCallTimeout(10 * 60 * 1000); return cc; }

Target:
protected ClientConfig createClientConfig() { return createClientConfig("", ""); }
Source:
public void run() { try { if (carbonMessage instanceof TextCarbonMessage) { String event = ((TextCarbonMessage) carbonMessage).getText(); sourceEventListener.onEvent(event); } else if (carbonMessage instanceof MapCarbonMessage) { Map<String, String> event = new HashMap<>(); Enumeration<String> mapNames = ((MapCarbonMessage) carbonMessage).getMapNames(); while (mapNames.hasMoreElements()) { String key = mapNames.nextElement(); event.put(key, ((MapCarbonMessage) carbonMessage).getValue(key)); } sourceEventListener.onEvent(event); } else { throw new JMSInputAdaptorRuntimeException("The message type of the JMS message is not supported!"); } if (carbonCallback != null) { carbonCallback.done(carbonMessage); } } catch (RuntimeException e) { throw new JMSInputAdaptorRuntimeException("Failed to process JMS message.", e); } }

Target:
public void run() { try { if (carbonMessage.getClass() == TextCarbonMessage.class) { String event = ((TextCarbonMessage) carbonMessage).getText(); sourceEventListener.onEvent(event); } else if (carbonMessage.getClass() == MapCarbonMessage.class) { Map<String, String> event = new HashMap<>(); MapCarbonMessage mapCarbonMessage = (MapCarbonMessage) carbonMessage; Enumeration<String> mapNames = mapCarbonMessage.getMapNames(); while (mapNames.hasMoreElements()) { String key = mapNames.nextElement(); event.put(key, mapCarbonMessage.getValue(key)); } sourceEventListener.onEvent(event); } else { throw new JMSInputAdaptorRuntimeException("The message type of the JMS message" + carbonMessage.getClass() + " is not supported!"); } if (carbonCallback != null) { carbonCallback.done(carbonMessage); } } catch (RuntimeException e) { throw new JMSInputAdaptorRuntimeException("Failed to process JMS message.", e); } }
Source:
public FixedBitIntReaderWriterV2(PinotDataBuffer dataBuffer, int numValues, int numBitsPerValue) { Preconditions .checkState(dataBuffer.size() == (int) (((long) numValues * numBitsPerValue + Byte.SIZE - 1) / Byte.SIZE)); _dataBitSet = PinotDataBitSetV2.createBitSet(dataBuffer, numBitsPerValue); _numBitsPerValue = numBitsPerValue; }

Target:
public FixedBitIntReaderWriterV2(PinotDataBuffer dataBuffer, int numValues, int numBitsPerValue) { Preconditions .checkState(dataBuffer.size() == (int) (((long) numValues * numBitsPerValue + Byte.SIZE - 1) / Byte.SIZE)); _dataBitSet = PinotDataBitSetV2.createBitSet(dataBuffer, numBitsPerValue); }
Source:
boolean areAllContainersRunning(Pod pod) { PodStatus podStatus = pod.getStatus(); if (podStatus == null) { return false; } List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses(); if (containerStatuses.isEmpty()) { return false; } for (ContainerStatus containerStatus : containerStatuses) { if (containerStatus != null) { ContainerStateWaiting waitingState = containerStatus.getState().getWaiting(); if (waitingState != null) { String waitingStateMsg = waitingState.getMessage(); if (waitingStateMsg != null && waitingStateMsg.contains("Back-off pulling image")) { runListener.error("Unable to pull Docker image \""+containerStatus.getImage()+"\". Check if image name is spelled correctly"); Jenkins jenkins = Jenkins.getInstanceOrNull(); if (jenkins != null) { Queue q = jenkins.getQueue(); for (Queue.Item item : q.getItems()) { Label itemLabel = item.getAssignedLabel(); if (itemLabel != null && isCorrespondingLabels(itemLabel.getDisplayName(), pod.getMetadata().getName())) { String itemTaskName = item.task.getFullDisplayName(); String jobName = getJobName(itemTaskName); if (jobName.equals("")) { LOGGER.log(Level.WARNING, "Unknown / Invalid job format name"); break; } q.cancel(item); break; } } } } return false; } if (containerStatus.getState().getTerminated() != null) { return false; } if (!containerStatus.getReady()) { return false; } } } return true; }

Target:
boolean areAllContainersRunning(Pod pod) { PodStatus podStatus = pod.getStatus(); if (podStatus == null) { return false; } List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses(); if (containerStatuses.isEmpty()) { return false; } for (ContainerStatus containerStatus : containerStatuses) { if (containerStatus != null) { ContainerStateWaiting waitingState = containerStatus.getState().getWaiting(); if (waitingState != null) { String waitingStateMsg = waitingState.getMessage(); if (waitingStateMsg != null && waitingStateMsg.contains("Back-off pulling image")) { String errorMsg = "Unable to pull Docker image \""+containerStatus.getImage()+"\". Check if image tag name is spelled correctly."; runListener.error(errorMsg); throw new InvalidDockerImageException(errorMsg); } return false; } if (containerStatus.getState().getTerminated() != null) { return false; } if (!containerStatus.getReady()) { return false; } } } return true; }
Source:
public LedgerMetadata parseConfig(byte[] bytes, Optional<Long> metadataStoreCtime) throws IOException { if (log.isDebugEnabled()) { log.debug("Deserializing {}", Base64.getEncoder().encodeToString(bytes)); } try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) { int metadataFormatVersion = readHeader(is); if (log.isDebugEnabled()) { log.debug("Format version detected", metadataFormatVersion); } switch (metadataFormatVersion) { case 3: return parseVersion3Config(is); case 2: return parseVersion2Config(is, metadataStoreCtime); case 1: return parseVersion1Config(is); default: throw new IOException( String.format("Metadata version not compatible. Expected between %d and %d, but got %d", LOWEST_COMPAT_METADATA_FORMAT_VERSION, CURRENT_METADATA_FORMAT_VERSION, metadataFormatVersion)); } } }

Target:
public LedgerMetadata parseConfig(byte[] bytes, Optional<Long> metadataStoreCtime) throws IOException { if (log.isDebugEnabled()) { log.debug("Deserializing {}", Base64.getEncoder().encodeToString(bytes)); } try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) { int metadataFormatVersion = readHeader(is); if (log.isDebugEnabled()) { String contentStr = ""; if (metadataFormatVersion <= METADATA_FORMAT_VERSION_2) { contentStr = ", content: " + new String(bytes, UTF_8); } log.debug("Format version detected{}", metadataFormatVersion, contentStr); } switch (metadataFormatVersion) { case METADATA_FORMAT_VERSION_3: return parseVersion3Config(is); case METADATA_FORMAT_VERSION_2: return parseVersion2Config(is, metadataStoreCtime); case METADATA_FORMAT_VERSION_1: return parseVersion1Config(is); default: throw new IOException( String.format("Metadata version not compatible. Expected between %d and %d, but got %d", LOWEST_COMPAT_METADATA_FORMAT_VERSION, CURRENT_METADATA_FORMAT_VERSION, metadataFormatVersion)); } } }
Source:
private static Map<String, String> parsePreparedStatementsHeaders(HttpServletRequest servletRequest) { ImmutableMap.Builder<String, String> preparedStatements = ImmutableMap.builder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_PREPARED_STATEMENT))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_PREPARED_STATEMENT); String statementName; String sqlString; try { statementName = urlDecode(nameValue.get(0)); sqlString = urlDecode(nameValue.get(1)); } catch (IllegalArgumentException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } SqlParser sqlParser = new SqlParser(); try { sqlParser.createStatement(sqlString, new ParsingOptions(true )); } catch (ParsingException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } preparedStatements.put(statementName, sqlString); } return preparedStatements.build(); }

Target:
private static Map<String, String> parsePreparedStatementsHeaders(HttpServletRequest servletRequest) { ImmutableMap.Builder<String, String> preparedStatements = ImmutableMap.builder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_PREPARED_STATEMENT))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_PREPARED_STATEMENT); String statementName; String sqlString; try { statementName = urlDecode(nameValue.get(0)); sqlString = urlDecode(nameValue.get(1)); } catch (IllegalArgumentException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } SqlParser sqlParser = new SqlParser(); try { sqlParser.createStatement(sqlString, new ParsingOptions(AS_DOUBLE )); } catch (ParsingException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } preparedStatements.put(statementName, sqlString); } return preparedStatements.build(); }
Source:
private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) return false; int as = a.lines.get(ai); int bs = b.lines.get(bi); int ae = a.lines.get(ai + 1); int be = b.lines.get(bi + 1); as = trimLeadingWhitespace(a.content, as, ae); bs = trimLeadingWhitespace(b.content, bs, be); ae = trimTrailingWhitespace(a.content, as, ae); be = trimTrailingWhitespace(b.content, bs, be); while (as < ae && bs < be) { byte ac = a.content[as]; byte bc = b.content[bs]; while (as < ae - 1 && isWhitespace(ac)) { as++; ac = a.content[as]; } while (bs < be - 1 && isWhitespace(bc)) { bs++; bc = b.content[bs]; } if (ac != bc) return false; as++; bs++; } return ae - as == be - bs; }

Target:
private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) return false; int as = a.lines.get(ai); int bs = b.lines.get(bi); int ae = a.lines.get(ai + 1); int be = b.lines.get(bi + 1); ae = trimTrailingWhitespace(a.content, as, ae); be = trimTrailingWhitespace(b.content, bs, be); while (as < ae && bs < be) { byte ac = a.content[as]; byte bc = b.content[bs]; while (as < ae - 1 && isWhitespace(ac)) { as++; ac = a.content[as]; } while (bs < be - 1 && isWhitespace(bc)) { bs++; bc = b.content[bs]; } if (ac != bc) return false; as++; bs++; } return as == ae && bs == be; }
Source:
public void testList() throws StripeException { final Transfer transfer = Transfer.retrieve(TRANSFER_ID); final TransferReversalCollection reversals = transfer.getReversals().list(null); assertNotNull(reversals); assertEquals(1, reversals.getData().size()); verifyRequest( APIResource.RequestMethod.GET, String.format("/v1/transfers/%s/reversals", transfer.getId()) ); }

Target:
public void testList() throws StripeException { final Transfer transfer = getTransferFixture(); final Map<String, Object> params = new HashMap<String, Object>(); params.put("limit", 1); final TransferReversalCollection reversals = transfer.getReversals().list(params); assertNotNull(reversals); verifyRequest( APIResource.RequestMethod.GET, String.format("/v1/transfers/%s/reversals", transfer.getId()), params ); }
Source:
public static void runFinalization() { if (runGC) { Runtime.getRuntime().gc(); runGC = false; } Runtime.getRuntime().runFinalization(); }

Target:
public static void runFinalization() { boolean shouldRunGC; synchronized(lock) { shouldRunGC = runGC; runGC = false; } if (shouldRunGC) { Runtime.getRuntime().gc(); } Runtime.getRuntime().runFinalization(); justRanFinalization = true; }
Source:
public static void setUp() { IKernelTrace trace = new TmfXmlKernelTraceStub(); IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE); IStatus status = trace.validate(null, filePath.toOSString()); if (!status.isOK()) { fail(status.getException().getMessage()); } try { trace.initTrace(null, filePath.toOSString(), TmfEvent.class); } catch (TmfTraceException e) { fail(e.getMessage()); } deleteSuppFiles(trace); ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(null, trace, null)); IAnalysisModule module = null; for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) { module = mod; } assertNotNull(module); module.schedule(); module.waitForCompletion(); fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID); assertNotNull(fModule); fTrace = trace; }

Target:
public void setUp() { IKernelTrace trace = new TmfXmlKernelTraceStub(); IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE); IStatus status = trace.validate(null, filePath.toOSString()); if (!status.isOK()) { fail(status.getException().getMessage()); } try { trace.initTrace(null, filePath.toOSString(), TmfEvent.class); } catch (TmfTraceException e) { fail(e.getMessage()); } deleteSuppFiles(trace); ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null)); IAnalysisModule module = null; for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) { module = mod; } assertNotNull(module); module.schedule(); module.waitForCompletion(); fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID); assertNotNull(fModule); fTrace = trace; }
Source:
public String toString() { return NLS.bind("{0} Succeeded, {1} Unstable, {2} Failed", new Object[] { numSuccess, numUnstable, numFailed }); }

Target:
public String toString() { return NLS.bind(Messages.BuildsView_BuildStatusSummary, new Object[] { numSuccess, numUnstable, numFailed }); }
Source:
private State parseRGBState(final String value) { if(!value.startsWith("RGB") || value.length() != 12) return null; try { final int red = Integer.valueOf(value.substring(3, 6)); final int green = Integer.valueOf(value.substring(6, 9)); final int blue = Integer.valueOf(value.substring(9, 12)); return new HSBType(new Color(red, green, blue)); } catch (NumberFormatException e) { logger.warn("cannot parse color from " + value, e); } return null; }

Target:
private State parseRGBState(final String value) { if (!value.startsWith("RGB") || value.length() != 12) return null; try { final int red = Integer.valueOf(value.substring(3, 6)); final int green = Integer.valueOf(value.substring(6, 9)); final int blue = Integer.valueOf(value.substring(9, 12)); return new HSBType(new Color(red, green, blue)); } catch (NumberFormatException e) { logger.warn("cannot parse color from {}", value, e); } return null; }
Source:
private void checkArray(final Field field) throws Violation { if (field.isAnnotationPresent(Immutable.Array.class)) { try { this.check(field.getType().getComponentType()); } catch (final ImmutabilityChecker.Violation ex) { throw new ImmutabilityChecker.Violation( String.format( "Field array component type '%s' is mutable", field.getType().getComponentType().getName() ), ex ); } } else { throw new ImmutabilityChecker.Violation( String.format( "Field '%s' is an array, which is mutable", field.getName() ) ); } }

Target:
private void checkArray(final Field field) throws Violation { if (field.isAnnotationPresent(Immutable.Array.class)) { try { this.check(field.getType().getComponentType()); } catch (final ImmutabilityChecker.Violation ex) { throw new ImmutabilityChecker.Violation( String.format( "Field array component type '%s' is mutable", field.getType().getComponentType().getName() ), ex ); } } else { throw new ImmutabilityChecker.Violation( String.format( "Field '%s' is an array and is not annotated with @Immutable.Array", field.getName() ) ); } }