auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static URL getResource(String name) { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); String callerName = Thread.currentThread().getStackTrace()[2].getClassName(); final String relativePath = callerName.replace('.', '/').concat(".class"); final String fullPath = loader.getResource(relativePath).getPath(); final String basePath = fullPath.substring(0, fullPath.indexOf(relativePath)); try { Enumeration<URL> resources = loader.getResources(name); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); if (resource.getPath().startsWith(basePath)) { return resource; } } } catch (IOException e) { return null; } return loader.getResource(name); }

Target:
public static URL getResource(String name) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); String callerName = Thread.currentThread().getStackTrace()[2].getClassName(); String relativePath = callerName.replace('.', '/').concat(".class"); String fullPath = loader.getResource(relativePath).getPath(); String basePath = fullPath.substring(0, fullPath.indexOf(relativePath)); try { Enumeration<URL> resources = loader.getResources(name); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); if (resource.getPath().startsWith(basePath)) { return resource; } } } catch (IOException e) { return null; } return loader.getResource(name); }
Source:
public MutationBuilder put(Column col, Bytes value) { Flutation.put(null, mutation, col, ColumnConstants.DATA_PREFIX | 0, value.toArray()); Flutation.put(null, mutation, col, ColumnConstants.WRITE_PREFIX | 1, WriteValue.encode(0, false, false)); return this; }

Target:
public MutationBuilder put(Column col, Bytes value) { Flutation.put(mutation, col, ColumnConstants.DATA_PREFIX | 0, value.toArray()); Flutation.put(mutation, col, ColumnConstants.WRITE_PREFIX | 1, WriteValue.encode(0, false, false)); return this; }
Source:
public QfdHelper(Connector connector, String indexTable, String shardTable, StoreConfig config, ShardBuilder<T> shardBuilder, TypeRegistry<String> typeRegistry, KeyValueIndex<T> keyValueIndex) throws TableExistsException, AccumuloSecurityException, AccumuloException, TableNotFoundException { this(connector, indexTable, shardTable, config, shardBuilder, typeRegistry, keyValueIndex, new SimpleLexiMetadataSerdeFactory()); }

Target:
public QfdHelper(Connector connector, String indexTable, String shardTable, StoreConfig config, ShardBuilder<T> shardBuilder, TypeRegistry<String> typeRegistry, KeyValueIndex<T> keyValueIndex) throws TableExistsException, AccumuloSecurityException, AccumuloException, TableNotFoundException { this(connector, indexTable, shardTable, config, shardBuilder, typeRegistry, keyValueIndex, new SimpleMetadataSerdeFactory()); }
Source:
public static Map<String, String> splitAndFilterEmptyMap(String s, String separator) { return Splitter.on(separator) .omitEmptyStrings() .trimResults() .withKeyValueSeparator("=") .split(s); }

Target:
private static Map<String, String> splitAndFilterEmptyMap(String s, String separator) { Map<String, String> result = new LinkedHashMap<>(); for (String o : Splitter.on(separator).omitEmptyStrings().split(s)) { String[] parts = o.trim().split("=", 2); if (parts.length == 2) result.put(parts[0].trim(), parts[1].trim()); } return result; }
Source:
public synchronized void processFoxml() throws XMLStreamException, IOException { if (getResult() == null) { final ApplicationContext context = new ClassPathXmlApplicationContext("spring/exported-foxml.xml"); this.result = (DummyHandler) context.getBean("dummyHandler"); this.fetcher = (DummyURLFetcher) context.getBean("dummyFetcher"); final Migrator m = (Migrator) context.getBean("migrator"); m.run(); ((ConfigurableApplicationContext) context).close(); } }

Target:
public synchronized void processFoxml() throws XMLStreamException, IOException { if (getResult() == null) { final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("spring/exported-foxml.xml"); this.result = (DummyHandler) context.getBean("dummyHandler"); this.fetcher = (DummyURLFetcher) context.getBean("dummyFetcher"); final Migrator m = (Migrator) context.getBean("migrator"); m.run(); context.close(); } }
Source:
public String createToken(final String to) { try { val token = UUID.randomUUID().toString(); val claims = new JwtClaims(); claims.setJwtId(token); claims.setIssuer(issuer); claims.setAudience(issuer); claims.setExpirationTimeMinutesInTheFuture(properties.getReset().getExpirationMinutes()); claims.setIssuedAtToNow(); val holder = ClientInfoHolder.getClientInfo(); if (holder != null) { if (properties.getReset().isCheckServerIpAddress()) { claims.setStringClaim("origin", holder.getServerIpAddress()); } if (properties.getReset().isCheckClientIpAddress()) { claims.setStringClaim("client", holder.getClientIpAddress()); } } claims.setSubject(to); LOGGER.debug("Creating password management token for [{}]", to); val json = claims.toJson(); LOGGER.debug("Encoding the generated JSON token..."); return this.cipherExecutor.encode(json); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } return null; }

Target:
public String createToken(final String to) { try { val token = UUID.randomUUID().toString(); val claims = new JwtClaims(); val resetProperties = properties.getReset(); claims.setJwtId(token); claims.setIssuer(issuer); claims.setAudience(issuer); claims.setExpirationTimeMinutesInTheFuture(resetProperties.getExpirationMinutes()); claims.setIssuedAtToNow(); val holder = ClientInfoHolder.getClientInfo(); if (holder != null) { if (resetProperties.isIncludeServerIpAddress()) { claims.setStringClaim("origin", holder.getServerIpAddress()); } if (resetProperties.isIncludeClientIpAddress()) { claims.setStringClaim("client", holder.getClientIpAddress()); } } claims.setSubject(to); LOGGER.debug("Creating password management token for [{}]", to); val json = claims.toJson(); LOGGER.debug("Encoding the generated JSON token..."); return this.cipherExecutor.encode(json); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } return null; }
Source:
public void run() { VanillaSelectionKeySet selectionKeys = null; try { socketChannel.configureBlocking(false); socketChannel.socket().setTcpNoDelay(true); socketChannel.socket().setSoTimeout(0); socketChannel.socket().setSoLinger(false, 0); if (builder.receiveBufferSize() > 0) { socketChannel.socket().setReceiveBufferSize(builder.receiveBufferSize()); } if (builder.sendBufferSize() > 0) { socketChannel.socket().setSendBufferSize(builder.sendBufferSize()); } final VanillaSelector selector = new VanillaSelector() .open() .register(socketChannel, SelectionKey.OP_READ, new Attached()); tailer = builder.chronicle().createTailer(); appender = builder.chronicle().createAppender(); sourceTcpHandler.setTailer(tailer); sourceTcpHandler.setAppender(appender); selectionKeys = selector.vanillaSelectionKeys(); if (selectionKeys != null) { vanillaNioLoop(selector, selectionKeys); } else { nioLoop(selector); } } catch (EOFException e) { if (running.get()) { logger.info("Connection died", socketChannel); } } catch (Exception e) { if (running.get()) { String msg = e.getMessage(); if (msg != null && (msg.contains("reset by peer") || msg.contains("Broken pipe") || msg.contains("was aborted by"))) { logger.info("Connection closed from the other end: ", socketChannel, e.getMessage()); } else { logger.info("Connection died", socketChannel, e); } } } finally { if (selectionKeys != null) { selectionKeys.clear(); } } try { close(); } catch (IOException e) { logger.warn("", e); } }

Target:
public void run() { sessionActive = true; VanillaSelectionKeySet selectionKeys = null; try { final VanillaSelector selector = new VanillaSelector() .open() .register(socketChannel, SelectionKey.OP_READ, new Attached()); tailer = builder.chronicle().createTailer(); appender = builder.chronicle().createAppender(); sourceTcpHandler.setTailer(tailer); sourceTcpHandler.setAppender(appender); selectionKeys = selector.vanillaSelectionKeys(); if (selectionKeys != null) { vanillaNioLoop(selector, selectionKeys); } else { nioLoop(selector); } } catch (InvalidEventHandlerException e) { if (running.get()) { logger.info("Connection died", socketChannel); } } catch (Exception e) { if (running.get()) { logger.info("Connection died", socketChannel, e); } } finally { if (selectionKeys != null) { selectionKeys.clear(); } } try { close(); } catch (IOException e) { logger.warn("", e); } }
Source:
public static Object eval(final String expression) { ExpressionCompiler compiler = new ExpressionCompiler(getRevisedExpression(expression), WID_PARSER_CONTEXT); if(KiePolicyHelper.isPolicyEnabled()) { return AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { return MVEL.executeExpression(compiler.compile(), new HashMap()); } }, KiePolicyHelper.getAccessContext()); } return MVEL.executeExpression(compiler.compile(), new HashMap()); }

Target:
public static Object eval(final String expression) { ExpressionCompiler compiler = new ExpressionCompiler(getRevisedExpression(expression), WID_PARSER_CONTEXT); if(KiePolicyHelper.isPolicyEnabled()) { return AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { return MVEL.executeExpression(compiler.compile(), new HashMap()); } }, KiePolicyHelper.getAccessContext()); } else { return MVEL.executeExpression(compiler.compile(), new HashMap()); } }
Source:
public int getFixedSize() { return SIZE_OF_LONG * 2 + 1; }

Target:
public int getFixedSize() { return Long.BYTES * 2 + 1; }
Source:
public boolean matchingValues(Object object1, Object object2) { final boolean equal; if (object1 == object2) { equal = true; } else if (object1 == null) { equal = "".equals(object2); } else if (object2 == null) { equal = "".equals(object1); } else { MatchSpec currentEObjectMatch = eObjectMatch; if (currentEObjectMatch != null && currentEObjectMatch.matches(object1)) { equal = currentEObjectMatch.matches(object2); } else if (object1 instanceof EObject) { if (object2 instanceof EObject) { equal = matchingEObjects((EObject)object1, (EObject)object2); } else { equal = false; } } else if (object1 instanceof String || object1 instanceof Integer || object1 instanceof Boolean) { equal = object1.equals(object2); } else if (object1.getClass().isArray() && object2.getClass().isArray()) { equal = matchingArrays(object1, object2); } else if (object1 instanceof FeatureMap.Entry && object2 instanceof FeatureMap.Entry) { FeatureMap.Entry featureMapEntry1 = (FeatureMap.Entry)object1; EStructuralFeature key1 = featureMapEntry1.getEStructuralFeature(); FeatureMap.Entry featureMapEntry2 = (FeatureMap.Entry)object2; EStructuralFeature key2 = featureMapEntry2.getEStructuralFeature(); if (key1 == key2) { Object value1 = featureMapEntry1.getValue(); Object value2 = featureMapEntry2.getValue(); equal = matchingValues(value1, value2); } else { equal = false; } } else { equal = object1.equals(object2); } } return equal; }

Target:
public boolean matchingValues(Object object1, Object object2) { final boolean equal; if (object1 == object2) { equal = true; } else if (object1 == null) { equal = "".equals(object2); } else if (object2 == null) { equal = "".equals(object1); } else { MatchSpec currentEObjectMatch = eObjectMatch; if (currentEObjectMatch != null && currentEObjectMatch.matches(object1)) { equal = currentEObjectMatch.matches(object2); } else if (object1 instanceof EObject) { if (object2 instanceof EObject) { equal = matchingEObjects((EObject)object1, (EObject)object2); } else { equal = false; } } else if (object1 instanceof String || object1 instanceof Integer || object1 instanceof Boolean) { equal = object1.equals(object2); } else if (object1.getClass().isArray() && object2.getClass().isArray()) { equal = matchingArrays(object1, object2); } else if (object1 instanceof FeatureMap.Entry && object2 instanceof FeatureMap.Entry) { FeatureMap.Entry featureMapEntry1 = (FeatureMap.Entry)object1; EStructuralFeature key1 = featureMapEntry1.getEStructuralFeature(); FeatureMap.Entry featureMapEntry2 = (FeatureMap.Entry)object2; EStructuralFeature key2 = featureMapEntry2.getEStructuralFeature(); if (key1.equals(key2)) { Object value1 = featureMapEntry1.getValue(); Object value2 = featureMapEntry2.getValue(); equal = matchingValues(value1, value2); } else { equal = false; } } else { equal = object1.equals(object2); } } return equal; }
Source:
public static void setUpOnce() { validator = new WikibaseDataModelValidator(); openTestDatasetStream(); try { parsedDataset = Rio.parse(testDataset, "http://test.dataset", RDFFormat.TURTLE); } catch (IOException ioe) { System.err.println("I/O trouble while reading from [" + TEST_DATASET_FILE_NAME + "]. This shouldn't happen here. Please re-run."); System.exit(1); } catch (RDFParseException rpe) { System.err.println("Parse error: " + rpe.getMessage() + " This shouldn't happen here. Please re-run."); } }

Target:
public static void setUpOnce() throws IOException, RDFParseException { validator = new WikibaseDataModelValidator(); goodDataset = openTestDatasetStream(GOOD_DATASET_FILE_NAME); goodParsedDataset = Rio.parse(goodDataset, BASE_URI, RDF_FORMAT); badDataset = openTestDatasetStream(BAD_DATASET_FILE_NAME); badParsedDataset = Rio.parse(badDataset, BASE_URI, RDF_FORMAT); }
Source:
public static void writeSegmentedCopyRatioPlot(final String sample_name, final String tnFile, final String preTnFile, final String segFile, final String outputDir, final Boolean log) { String logArg = "FALSE"; if(log){ logArg = "TRUE"; } final RScriptExecutor executor = new RScriptExecutor(); executor.addScript(new Resource(R_SCRIPT, CopyRatioSegmentedPlotter.class)); executor.addArgs("--args", "--sample_name="+sample_name, "--targets_file="+tnFile, "--pre_tn_file="+preTnFile, "--seg_file="+segFile, "--output_dir="+outputDir, "--log2_input="+logArg); executor.exec(); }

Target:
public static void writeSegmentedCopyRatioPlot(final String sample_name, final String tnFile, final String preTnFile, final String segFile, final String outputDir, final Boolean log) { String logArg = log ? "TRUE" : "FALSE"; final RScriptExecutor executor = new RScriptExecutor(); executor.addScript(new Resource(R_SCRIPT, CopyRatioSegmentedPlotter.class)); executor.addArgs("--args", "--sample_name="+sample_name, "--targets_file="+tnFile, "--pre_tn_file="+preTnFile, "--seg_file="+segFile, "--output_dir="+outputDir, "--log2_input="+logArg); executor.exec(); }
Source:
public static String getCurrentBranch(IProject project) throws CoreException { if (project == null) { return null; } Repository repo = EGitUtils.getRepository(project); if (repo == null) { return null; } String currentBranch = EGitUtils.getCurrentBranch(repo); repo.close(); return currentBranch; }

Target:
public static String getCurrentBranch(IProject project) throws CoreException { if (project == null) { return null; } try (Repository repo = EGitUtils.getRepository(project)) { if (repo == null) { return null; } return EGitUtils.getCurrentBranch(repo); } }
Source:
private Pair<ArrayList<IndexEntry>, Offset> addPutEntries(Offset prevEntryEndOffset, IndexSegment indexSegment, int count, long size, long expiresAtMs) throws IOException, StoreException { ArrayList<IndexEntry> indexEntrys = new ArrayList<>(); for (int i = 0; i < count; i++) { state.appendToLog(size); FileSpan fileSpan = state.log.getFileSpanForMessage(prevEntryEndOffset, size); IndexEntry entry; if (indexSegment != null) { entry = new IndexEntry(state.getUniqueId(), IndexValueTest.getIndexValue(size, prevEntryEndOffset, expiresAtMs, state.time.seconds(), IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, PersistentIndex.VERSION_0)); indexSegment.addEntry(entry, fileSpan.getEndOffset()); } else { entry = new IndexEntry(state.getUniqueId(), IndexValueTest.getIndexValue(size, prevEntryEndOffset, expiresAtMs, state.time.seconds(), IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, PersistentIndex.CURRENT_VERSION)); state.index.addToIndex(entry, fileSpan); } indexEntrys.add(entry); prevEntryEndOffset = fileSpan.getEndOffset(); } return new Pair<>(indexEntrys, prevEntryEndOffset); }

Target:
private List<IndexEntry> addPutEntries(Offset prevEntryEndOffset, IndexSegment indexSegment, int count, long size, long expiresAtMs) throws IOException, StoreException { List<IndexEntry> indexEntries = new ArrayList<>(); for (int i = 0; i < count; i++) { state.appendToLog(size); FileSpan fileSpan = state.log.getFileSpanForMessage(prevEntryEndOffset, size); IndexEntry entry; if (indexSegment != null) { entry = new IndexEntry(state.getUniqueId(), IndexValueTest.getIndexValue(size, prevEntryEndOffset, expiresAtMs, state.time.milliseconds(), IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, IndexValue.SERVICE_CONTAINER_ID_DEFAULT_VALUE, indexSegment.getVersion())); indexSegment.addEntry(entry, fileSpan.getEndOffset()); } else { entry = new IndexEntry(state.getUniqueId(), new IndexValue(size, prevEntryEndOffset, (byte) 0, expiresAtMs, state.time.milliseconds())); state.index.addToIndex(entry, fileSpan); } indexEntries.add(entry); prevEntryEndOffset = fileSpan.getEndOffset(); } return indexEntries; }
Source:
private static int getPoolSize(Configuration config) { int poolSize = config.getInt(HConstants.HBASE_CLIENT_IPC_POOL_SIZE, 1); if (poolSize <= 0) { LOG.warn("{} must be positive.", HConstants.HBASE_CLIENT_IPC_POOL_SIZE); return 1; } else { return poolSize; } }

Target:
private static int getPoolSize(Configuration config) { int poolSize = config.getInt(HConstants.HBASE_CLIENT_IPC_POOL_SIZE, 1); if (poolSize <= 0) { LOG.warn("{} must be positive. Using default value: 1", HConstants.HBASE_CLIENT_IPC_POOL_SIZE); return 1; } else { return poolSize; } }
Source:
public V get(K key) { V cached; if ((cached = this.cache.get(key)) != null) { if (this.size < this.maxSize / 2) { return cached; } try { this.readLock.lock(); this.queue.add(key); this.queue.remove(key); return cached; } finally { this.readLock.unlock(); } } this.writeLock.lock(); try { if ((cached = this.cache.get(key)) != null) { this.queue.add(key); this.queue.remove(key); return cached; } int cacheSize = this.size; if (cacheSize == this.maxSize) { K leastUsed = this.queue.poll(); if (leastUsed != null) { this.cache.remove(leastUsed); cacheSize--; } } V value = this.generator.apply(key); this.queue.add(key); this.cache.put(key, value); this.size = cacheSize + 1; return value; } finally { this.writeLock.unlock(); } }

Target:
public V get(K key) { V cached; if ((cached = this.cache.get(key)) != null) { if (this.size < this.maxSize / 2) { return cached; } try { this.readLock.lock(); this.queue.add(key); this.queue.remove(key); return cached; } finally { this.readLock.unlock(); } } this.writeLock.lock(); try { if ((cached = this.cache.get(key)) != null) { this.queue.add(key); this.queue.remove(key); return cached; } V value = this.generator.apply(key); int cacheSize = this.size; if (cacheSize == this.maxSize) { K leastUsed = this.queue.poll(); if (leastUsed != null) { this.cache.remove(leastUsed); cacheSize--; } } this.queue.add(key); this.cache.put(key, value); this.size = cacheSize + 1; return value; } finally { this.writeLock.unlock(); } }
Source:
private void configureColor() { ChatPrefs chatPrefs = preferencesService.getPreferences().getChatPrefs(); ObjectProperty<Color> colorProperty = null; Color color = null; if (playerInfoBean.getModeratorInChannels().size() > 0) { colorProperty = chatPrefs.modsChatColorProperty(); } else if (playerInfoBean.isFriend()) { colorProperty = chatPrefs.friendsChatColorProperty(); } else if (playerInfoBean.isFoe()) { colorProperty = chatPrefs.foesChatColorProperty(); } else if (playerInfoBean.getUsername().equals(userService.getUsername())) { colorProperty = chatPrefs.selfChatColorProperty(); } if (!chatPrefs.getPrettyColors() && colorProperty == null) { if (playerInfoBean.isChatOnly()) { colorProperty = chatPrefs.ircChatColorProperty(); } else { colorProperty = chatPrefs.othersChatColorProperty(); } } else if (chatPrefs.getPrettyColors() && colorProperty == null) { color = ColorGeneratorUtil.generatePrettyHexColor(); ChatUser chatUser = chatService.getChatUser(playerInfoBean.getUsername()); try { if (chatUser.getColor() == null) { chatUser.setColor(color); } else { color = chatUser.getColor(); } } catch (NullPointerException e) { logger.warn("Could not generate color for {}", playerInfoBean.getUsername()); } } if (colorProperty != null) { color = colorProperty.get(); addColorListenerToLabels(colorProperty); } usernameLabel.setTextFill(color); clanLabel.setTextFill(color); }

Target:
private void configureColor() { ChatPrefs chatPrefs = preferencesService.getPreferences().getChat(); if (playerInfoBean.getSocialStatus() == SELF) { getStyleClass().add(CSS_CLASS_SELF); return; } Color color = null; ChatUser chatUser = chatService.createOrGetChatUser(playerInfoBean.getUsername()); if (chatPrefs.getChatColorMode().equals(CUSTOM)) { if (chatPrefs.getUserToColor().containsKey(playerInfoBean.getUsername())) { color = chatPrefs.getUserToColor().get(playerInfoBean.getUsername()); } chatPrefs.getUserToColor().addListener((MapChangeListener<? super String, ? super Color>) change -> { if (playerInfoBean.getUsername().equals(change.getKey())) { Color newColor = chatPrefs.getUserToColor().get(playerInfoBean.getUsername()); assignColor(newColor); } }); } else if (chatPrefs.getChatColorMode().equals(ChatColorMode.RANDOM) && colorsAllowedInPane) { color = ColorGeneratorUtil.generateRandomHexColor(); } chatUser.setColor(color); assignColor(color); }
Source:
public String toString() { return super.toString() + " TruncationHandleMessage truncation handle id: " + CoreUtils.hsIdToString(m_truncationHandle); }

Target:
public String toString() { return super.toString() + " TruncationHandleMessage truncation handle id: " + TxnEgo.txnIdToString(m_truncationHandle); }
Source:
public final void updateEquivalences(ImmutableSet<EquivalenceGraph> graphs) throws WriteException { metricRegistry.meter(updateEquivalences + METER_CALLED).mark(); ImmutableMap<EquivalenceGraph, ListenableFuture<Resolved<Content>>> graphsContent = graphs .stream() .distinct() .collect(MoreCollectors.toImmutableMap( graph -> graph, graph -> contentStore.resolveIds(graph.getEquivalenceSet()) )); ImmutableList.Builder<ResultSetFuture> futureBuilder = ImmutableList.builder(); for (Map.Entry<EquivalenceGraph, ListenableFuture<Resolved<Content>>> entry : graphsContent.entrySet()) { EquivalenceGraph graph = entry.getKey(); ImmutableList<Item> graphItems = get(entry.getValue()) .getResources() .filter(Item.class) .toList(); for (Item item : graphItems) { ImmutableList<Broadcast> broadcasts = item.getBroadcasts() .stream() .filter(Broadcast::isActivelyPublished) .collect(MoreCollectors.toImmutableList()); for (Broadcast broadcast : broadcasts) { Item copy = item.copy(); copy.setBroadcasts(ImmutableSet.of(broadcast)); futureBuilder.addAll(updateEquivalentContent( item.getSource(), broadcast, graph, equivItems(copy, broadcast, graphItems) )); } } } ImmutableList<ResultSetFuture> futures = futureBuilder.build(); metricRegistry.histogram(updateEquivalences + "histogram.parallelWrites") .update(futures.size()); try { for (ResultSetFuture future : futures) { future.get(); } } catch (Exception e) { metricRegistry.meter(updateEquivalences + METER_FAILURE).mark(); throw new WriteException(e); } }

Target:
public final void updateEquivalences(ImmutableSet<EquivalenceGraph> graphs) throws WriteException { metricRegistry.meter(updateEquivalences + METER_CALLED).mark(); ImmutableMap<EquivalenceGraph, ListenableFuture<Resolved<Content>>> graphsContent = graphs .stream() .distinct() .collect(MoreCollectors.toImmutableMap( graph -> graph, graph -> contentStore.resolveIds(graph.getEquivalenceSet()) )); ImmutableList.Builder<ResultSetFuture> futureBuilder = ImmutableList.builder(); for (Map.Entry<EquivalenceGraph, ListenableFuture<Resolved<Content>>> entry : graphsContent.entrySet()) { EquivalenceGraph graph = entry.getKey(); ImmutableList<Item> graphItems = get(entry.getValue()) .getResources() .filter(Item.class) .toList(); for (Item item : graphItems) { ImmutableList<Broadcast> broadcasts = item.getBroadcasts() .stream() .filter(Broadcast::isActivelyPublished) .collect(MoreCollectors.toImmutableList()); for (Broadcast broadcast : broadcasts) { Item copy = item.copy(); copy.setBroadcasts(ImmutableSet.of(broadcast)); futureBuilder.addAll(updateEquivalentContent( item.getSource(), broadcast, graph, equivItems(copy, broadcast, graphItems) )); } } } ImmutableList<ResultSetFuture> futures = futureBuilder.build(); metricRegistry.histogram(updateEquivalences + "histogram.parallelWrites") .update(futures.size()); try { Futures.allAsList(futures).get(); } catch (Exception e) { metricRegistry.meter(updateEquivalences + METER_FAILURE).mark(); throw new WriteException(e); } }
Source:
public OIndexRIDContainer(String name, boolean durableNonTxMode, AtomicLong bonsayFileId) { if (bonsayFileId.get() == 0) { fileId = resolveFileIdByName(name + INDEX_FILE_EXTENSION); bonsayFileId.set(fileId); } else { fileId = bonsayFileId.get(); } underlying = new HashSet<>(); isEmbedded = true; this.durableNonTxMode = durableNonTxMode; }

Target:
public OIndexRIDContainer(String name, boolean durableNonTxMode, AtomicLong bonsayFileId) { long gotFileId = bonsayFileId.get(); if (gotFileId == 0) { gotFileId = resolveFileIdByName(name + INDEX_FILE_EXTENSION); bonsayFileId.set(gotFileId); } this.fileId = gotFileId; underlying = new HashSet<>(); isEmbedded = true; this.durableNonTxMode = durableNonTxMode; }
Source:
public boolean suppresses(Rule rule) { if (jjtGetChild(0) instanceof ASTMarkerAnnotation) { return false; } if ("SuppressWarnings".equals(getAnnotationName()) || "java.lang.SuppressWarnings".equals(getAnnotationName())) { for (ASTLiteral element : findDescendantsOfType(ASTLiteral.class)) { if (element.hasImageEqualTo("\"PMD\"") || element.hasImageEqualTo("\"PMD." + rule.getName() + "\"") || element.hasImageEqualTo("\"all\"") || element.hasImageEqualTo("\"serial\"") && SERIAL_RULES.contains(rule.getName()) || element.hasImageEqualTo("\"unused\"") && UNUSED_RULES.contains(rule.getName())) { return true; } } } return false; }

Target:
public boolean suppresses(Rule rule) { if (jjtGetChild(0) instanceof ASTMarkerAnnotation) { return false; } if (isSuppressWarnings()) { for (ASTLiteral element : findDescendantsOfType(ASTLiteral.class)) { if (element.hasImageEqualTo("\"PMD\"") || element.hasImageEqualTo("\"PMD." + rule.getName() + "\"") || element.hasImageEqualTo("\"all\"") || element.hasImageEqualTo("\"serial\"") && SERIAL_RULES.contains(rule.getName()) || element.hasImageEqualTo("\"unused\"") && UNUSED_RULES.contains(rule.getName())) { return true; } } } return false; }
Source:
public void put(int fieldId, Datum value) { this.offset = -1; values[fieldId] = value; }

Target:
public void put(int fieldId, Datum value) { values[fieldId] = value; }
Source:
public void returnsCorrectNamesSet() throws Exception { final String body = "441 N Wolfe Rd, Sunnyvale, CA 94085"; final RqMultipart multi = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), new FormattedText( "Content-Length: %s", body.getBytes().length ).asString(), "Content-Disposition: form-data; name=\"address\"" ), new RqWithHeaders( new RqFake("", "", ""), "Content-Length: 0", "Content-Disposition: form-data; name=\"data\"; filename=\"a.bin\"" ) ); try { MatcherAssert.assertThat( multi.names(), Matchers.<Iterable<String>>equalTo( new HashSet<String>(Arrays.asList("address", "data")) ) ); } finally { multi.body().close(); } }

Target:
public void returnsCorrectNamesSet() throws Exception { final String body = "441 N Wolfe Rd, Sunnyvale, CA 94085"; final RqMultipart multi = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), new FormattedText( RqMtFakeTest.CONTENT_LENGTH, body.getBytes().length ).asString(), new FormattedText( RqMtFakeTest.CONTENT_DISP, "name=\"address\"" ).asString() ), new RqWithHeaders( new RqFake("", "", ""), new FormattedText(RqMtFakeTest.CONTENT_LENGTH, 0).asString(), new FormattedText( RqMtFakeTest.CONTENT_DISP, "name=\"data\"; filename=\"a.bin\"" ).asString() ) ); try { MatcherAssert.assertThat( multi.names(), Matchers.<Iterable<String>>equalTo( new HashSet<String>(Arrays.asList("address", "data")) ) ); } finally { multi.body().close(); } }
Source:
private void validateReportIndex(GraphContext context) { ReportService reportService = new ReportService(context); ReportModel reportModel = reportService.getUniqueByProperty( ReportModel.TEMPLATE_PATH, CreateReportIndexRuleProvider.TEMPLATE); Path appReportPath = reportService.getReportDirectory().resolve(reportModel.getReportFilename()); TestReportIndexReportUtil util = new TestReportIndexReportUtil(); util.loadPage(appReportPath); Assert.assertTrue(util.checkIncidentByCategoryRow("optional", 291, 2306)); Assert.assertTrue(util.checkIncidentByCategoryRow("mandatory", 0, 0)); Assert.assertTrue(util.checkIncidentByCategoryRow("information", 10, 0)); Assert.assertTrue(util.checkIncidentByCategoryRow("cloud-mandatory", 3, 3)); Assert.assertTrue(util.checkIncidentByCategoryRow("mandatory", 0, 0)); }

Target:
private void validateReportIndex(GraphContext context) { ReportService reportService = new ReportService(context); ReportModel reportModel = reportService.getUniqueByProperty( ReportModel.TEMPLATE_PATH, CreateReportIndexRuleProvider.TEMPLATE); Path appReportPath = reportService.getReportDirectory().resolve(reportModel.getReportFilename()); TestReportIndexReportUtil util = new TestReportIndexReportUtil(); util.loadPage(appReportPath); Assert.assertTrue(util.checkIncidentByCategoryRow("optional", 291, 2306)); Assert.assertTrue(util.checkIncidentByCategoryRow("mandatory", 0, 0)); Assert.assertTrue(util.checkIncidentByCategoryRow("information", 10, 0)); Assert.assertTrue(util.checkIncidentByCategoryRow("cloud-mandatory", 3, 3)); Assert.assertTrue(util.checkIncidentByCategoryRow("potential", 0, 0)); }
Source:
protected List<E> getFilteredList() { List<E> filteredValues = new ArrayList<>(); Collections.addAll(filteredValues, enumeration.getEnumConstants()); if (excludedValues != null) { for (E element : excludedValues) { filteredValues.remove(element); } } return filteredValues; }

Target:
private List<E> getFilteredList() { List<E> filteredValues = new ArrayList<>(); Collections.addAll(filteredValues, enumeration.getEnumConstants()); if (excludedValues != null) { for (E element : excludedValues) { filteredValues.remove(element); } } return filteredValues; }
Source:
public boolean isTopicMute(Message message) { return mutedTopics.contains(message.getStream().getId() + message.getSubject()); }

Target:
public boolean isTopicMute(Message message) { return mutedTopics.contains(message.concatStreamAndTopic()); }
Source:
public boolean isPartitionedOn(Collection<Symbol> columns, Set<Symbol> knownConstants) { for (ArgumentBinding argument : arguments) { if (argument.isConstant()) { continue; } if (!argument.isVariable()) { return false; } if (!knownConstants.contains(argument.getColumn()) && !columns.contains(argument.getColumn())) { return false; } } return true; }

Target:
public boolean isPartitionedOn(Collection<Symbol> columns, Set<Symbol> knownConstants) { for (ArgumentBinding argument : arguments) { if (argument.isConstant()) { continue; } if (!argument.isSymbolReference()) { return false; } if (!knownConstants.contains(argument.getSymbol()) && !columns.contains(argument.getSymbol())) { return false; } } return true; }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { this.message = (SwrveMessage) extras.getSerializable("inAppMessage"); this.hideToolbar = extras.getBoolean("hideToolbar", true); this.minSampleSize = extras.getInt("minSampleSize", 1); this.messenger = (Messenger)extras.get("messenger"); } } SwrveOrientation deviceOrientation = getDeviceOrientation(); SwrveMessageFormat format = message.getFormat(deviceOrientation); if (format == null) { format = message.getFormats().get(0); if (format.getOrientation() != deviceOrientation) { if (format.getOrientation() == SwrveOrientation.Landscape) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } } if (message != null) { if (hideToolbar) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); } try { SwrveMessageView view = new SwrveMessageView(this, messenger, message, format, minSampleSize); setContentView(view); if(savedInstanceState == null) { view.notifyOfImpression(message, format); } } catch (SwrveMessageViewBuildException e) { e.printStackTrace(); } } else { finish(); } }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sdk = (SwrveBase)SwrveSDK.getInstance(); if (sdk == null) { finish(); return; } Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { int messageId = extras.getInt(MESSAGE_ID_KEY); message = sdk.getMessageForId(messageId); SwrveConfigBase config = sdk.getConfig(); this.hideToolbar = config.isHideToolbar(); this.minSampleSize = config.getMinSampleSize(); this.defaultBackgroundColor = config.getDefaultBackgroundColor(); } } if (message == null) { finish(); return; } SwrveOrientation deviceOrientation = getDeviceOrientation(); format = message.getFormat(deviceOrientation); if (format == null) { format = message.getFormats().get(0); } if (message.getFormats().size() == 1) { if (format.getOrientation() == SwrveOrientation.Landscape) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (!hideToolbar) { setTheme(R.style.Theme_InAppMessageWithToolbar); } try { SwrveMessageView view = new SwrveMessageView(this, message, format, minSampleSize, defaultBackgroundColor); setContentView(view); if(savedInstanceState == null) { notifyOfImpression(format); } } catch (SwrveMessageViewBuildException e) { SwrveLogger.e(LOG_TAG, "Error while creating the SwrveMessageView", e); } }
Source:
public ConfigBuilder readFrom(View<?> view) { if (view instanceof Dataset && view instanceof FileSystemDataset) { FileSystemDataset dataset = (FileSystemDataset) view; conf.set(KITE_PARTITION_DIR, String.valueOf(dataset.getDescriptor().getLocation())); } withType(view.getType()); return readFrom(view.getUri()); }

Target:
public ConfigBuilder readFrom(View<?> view) { if (view instanceof FileSystemDataset) { FileSystemDataset dataset = (FileSystemDataset) view; conf.set(KITE_PARTITION_DIR, String.valueOf(dataset.getDescriptor().getLocation())); } withType(view.getType()); return readFrom(view.getUri()); }
Source:
public HadoopDruidIndexerConfig( final @JsonProperty("schema") HadoopIngestionSpec schema ) { this.columnConfig = columnConfig; this.schema = schema; this.pathSpec = jsonMapper.convertValue(schema.getIOConfig().getPathSpec(), PathSpec.class); for (Map.Entry<DateTime, List<HadoopyShardSpec>> entry : schema.getTuningConfig().getShardSpecs().entrySet()) { if (entry.getValue() == null || entry.getValue().isEmpty()) { continue; } final ShardSpec actualSpec = entry.getValue().get(0).getActualSpec(); shardSpecLookups.put( entry.getKey(), actualSpec.getLookup( Lists.transform( entry.getValue(), new Function<HadoopyShardSpec, ShardSpec>() { @Nullable @Override public ShardSpec apply(@Nullable HadoopyShardSpec input) { return input.getActualSpec(); } } ) ) ); for (HadoopyShardSpec hadoopyShardSpec : entry.getValue()) { hadoopShardSpecLookup.put(hadoopyShardSpec.getActualSpec(), hadoopyShardSpec); } } }

Target:
public HadoopDruidIndexerConfig( final @JsonProperty("schema") HadoopIngestionSpec schema ) { this.columnConfig = columnConfig; this.schema = schema; this.pathSpec = jsonMapper.convertValue(schema.getIOConfig().getPathSpec(), PathSpec.class); for (Map.Entry<DateTime, List<HadoopyShardSpec>> entry : schema.getTuningConfig().getShardSpecs().entrySet()) { if (entry.getValue() == null || entry.getValue().isEmpty()) { continue; } final ShardSpec actualSpec = entry.getValue().get(0).getActualSpec(); shardSpecLookups.put( entry.getKey(), actualSpec.getLookup( Lists.transform( entry.getValue(), new Function<HadoopyShardSpec, ShardSpec>() { @Override public ShardSpec apply(HadoopyShardSpec input) { return input.getActualSpec(); } } ) ) ); for (HadoopyShardSpec hadoopyShardSpec : entry.getValue()) { hadoopShardSpecLookup.put(hadoopyShardSpec.getActualSpec(), hadoopyShardSpec); } } }
Source:
public void committed(long epoch, Layout layout, boolean force) throws WrongEpochException { CompletableFuture<Boolean>[] commitList = layout.getLayoutServers().stream() .map(x -> { CompletableFuture<Boolean> cf = new CompletableFuture<>(); try { if (force) { cf = getRuntimeLayout(layout).getLayoutClient(x).force(layout); } else { cf = getRuntimeLayout(layout).getLayoutClient(x).committed(epoch, layout); } } catch (NetworkException e) { cf.completeExceptionally(e); } return cf; }) .toArray(CompletableFuture[]::new); int responses = 0; for (CompletableFuture cf : commitList) { try { CFUtils.getUninterruptibly(cf, WrongEpochException.class, TimeoutException.class, NetworkException.class, NoBootstrapException.class); responses++; } catch (WrongEpochException e) { log.warn("committed: Error while force committing", e); } catch (NoBootstrapException nbe) { log.warn("committed: Error while force committing", nbe); } catch (TimeoutException | NetworkException e) { log.warn("committed: Error while committing", e); } } log.debug("committed: Successful responses={}, responses={}", commitList.length, responses); }

Target:
public void committed(long epoch, Layout layout, boolean force) throws WrongEpochException { CompletableFuture<Boolean>[] commitList = layout.getLayoutServers().stream() .map(x -> { CompletableFuture<Boolean> cf = new CompletableFuture<>(); try { if (force) { cf = getRuntimeLayout(layout).getLayoutClient(x).force(layout); } else { cf = getRuntimeLayout(layout).getLayoutClient(x).committed(epoch, layout); } } catch (NetworkException e) { cf.completeExceptionally(e); } return cf; }) .toArray(CompletableFuture[]::new); int responses = 0; for (CompletableFuture cf : commitList) { try { CFUtils.getUninterruptibly(cf, WrongEpochException.class, TimeoutException.class, NetworkException.class, NoBootstrapException.class); responses++; } catch (WrongEpochException e) { if (!force) { throw e; } log.warn("committed: encountered exception", e); } catch (NoBootstrapException | TimeoutException | NetworkException e) { log.warn("committed: encountered exception", e); } } log.debug("committed: Successful requests={}, responses={}", commitList.length, responses); }
Source:
public void cleanUp() throws Exception { if (container.isStarted()) { container.stop(); if(container.isStarted()){ throw new Exception("Could not stop container"); } } if(new File(COPY_PATH).isDirectory()){ if(new File(COPY_PATH+File.separatorChar+SERVER_CONFIG).exists()){ new File(COPY_PATH+File.separatorChar+SERVER_CONFIG).delete(); } new File(COPY_PATH).delete(); } }

Target:
public void cleanUp() throws Exception { if (container.isStarted()) { container.stop(); if(container.isStarted()){ throw new Exception("Could not stop container"); } } if(targetDirectory != null){ if(copyConfigFile != null && copyConfigFile.exists()){ copyConfigFile.delete(); } targetDirectory.delete(); } }
Source:
private <T> T constructWithConstructor( Class<T> clazz, Constructor<?> constructor, Set<Class<?>> autoConstructionCandidates) { Parameter[] parameters = constructor.getParameters(); Object[] values = new Object[parameters.length]; for (int i = 0; i < parameters.length; i++) { values[i] = getValueForParameter(parameters[i]); if (values[i] == null) { Class<?> parameterType = parameters[i].getType(); if (canAutoConstruct(parameterType) && !autoConstructionCandidates.contains(parameterType)) { try { values[i] = construct(parameterType, autoConstructionCandidates); } catch (IllegalArgumentException | IllegalStateException e) { logger.debug("Could not build class as the following type could not be constructed {}", clazz, parameterType, e); return null; } } else { logger.error("Could not build class as the following type was not found {}", clazz, parameterType); return null; } } } return instantiate(clazz, constructor, values); }

Target:
private <T> T constructWithConstructor( Class<T> clazz, Constructor<?> constructor, Set<Class<?>> autoConstructionCandidates) { Parameter[] parameters = constructor.getParameters(); Object[] values = new Object[parameters.length]; for (int i = 0; i < parameters.length; i++) { values[i] = getValueForParameter(parameters[i]); if (values[i] == null) { Class<?> parameterType = parameters[i].getType(); if (canAutoConstruct(parameterType) && !autoConstructionCandidates.contains(parameterType)) { try { values[i] = construct(parameterType, autoConstructionCandidates); } catch (IllegalArgumentException | IllegalStateException e) { logger.error("Could not build class as the following type could not be constructed {}", clazz, parameterType, e); return null; } } else { logger.error("Could not build class as the following type was not found {}", clazz, parameterType); return null; } } } return instantiate(clazz, constructor, values); }
Source:
default Future<Long> write(ByteBuf src, Callback<Long> callback) { int numBuffers = src.nioBufferCount(); if (numBuffers == 1) { return write(src.nioBuffer(), (result, exception) -> { if (result != 0) { src.readerIndex(src.readerIndex() + (int) result.longValue()); } callback.onCompletion(result, exception); }); } else { ByteBuffer[] buffers = src.nioBuffers(); AtomicLong size = new AtomicLong(0); AtomicInteger index = new AtomicInteger(0); FutureResult<Long> futureResult = new FutureResult<Long>(); Callback<Long> cb = new Callback<Long>() { @Override public void onCompletion(Long result, Exception exception) { index.addAndGet(1); size.addAndGet(result); if (result != 0) { src.readerIndex(src.readerIndex() + (int) result.longValue()); } if (exception != null) { futureResult.done(size.get(), exception); if (callback != null) { callback.onCompletion(size.get(), exception); } } else { if (index.get() == buffers.length) { futureResult.done(size.get(), exception); if (callback != null) { callback.onCompletion(size.get(), exception); } } } } }; for (int i = 0; i < buffers.length; i++) { write(buffers[i], cb); } return futureResult; } }

Target:
default Future<Long> write(ByteBuf src, Callback<Long> callback) { if (src == null) { throw new IllegalArgumentException("Source ByteBuf cannot be null"); } int numBuffers = src.nioBufferCount(); FutureResult<Long> futureResult = new FutureResult<>(); Callback<Long> singleBufferCallback = (result, exception) -> { if (result != 0) { src.readerIndex(src.readerIndex() + (int) result.longValue()); } futureResult.done(result.longValue(), exception); if (callback != null) { callback.onCompletion(result, exception); } }; if (numBuffers < 1) { ByteBuffer byteBuffer = ByteBuffer.allocate(src.readableBytes()); src.getBytes(src.readerIndex(), byteBuffer); write(byteBuffer, singleBufferCallback); } else if (numBuffers == 1) { write(src.nioBuffer(), singleBufferCallback); } else { ByteBuffer[] buffers = src.nioBuffers(); AtomicLong size = new AtomicLong(0); AtomicInteger index = new AtomicInteger(0); AtomicBoolean callbackInvoked = new AtomicBoolean(false); Callback<Long> cb = (result, exception) -> { index.addAndGet(1); size.addAndGet(result); if (result != 0) { src.readerIndex(src.readerIndex() + (int) result.longValue()); } if ((exception != null || index.get() == buffers.length) && callbackInvoked.compareAndSet(false, true)) { futureResult.done(size.get(), exception); if (callback != null) { callback.onCompletion(size.get(), exception); } } }; for (int i = 0; i < buffers.length; i++) { write(buffers[i], cb); } } return futureResult; }
Source:
private static Tuple3<PriorityQueue<OptimizedEvaluator>, Double, Integer> getOptimizedEvaluators(final Cost cost) { final PriorityQueue<OptimizedEvaluator> optimizedEvaluatorQueue = new PriorityQueue<>(cost.getComputeTaskCosts().size(), COMP_UNIT_COST_INV_COMPARATOR); double compUnitCostSum = 0; int numUnitsTotal = 0; for (final Cost.ComputeTaskCost computeTaskCost : cost.getComputeTaskCosts()) { final int numBlocks = computeTaskCost.getDataInfo().getNumBlocks(); final double compUnitCost = computeTaskCost.getComputeCost() / numBlocks; final double compUnitCostInv = 1 / compUnitCost; compUnitCostSum += compUnitCost; numUnitsTotal += numBlocks; optimizedEvaluatorQueue.add(new OptimizedEvaluator( computeTaskCost.getId(), computeTaskCost.getDataInfo(), compUnitCostInv)); } return new Tuple3<>(optimizedEvaluatorQueue, compUnitCostSum, numUnitsTotal); }

Target:
private static Tuple3<PriorityQueue<OptimizedEvaluator>, Double, Integer> getOptimizedEvaluators(final Cost cost) { final PriorityQueue<OptimizedEvaluator> optimizedEvaluatorQueue = new PriorityQueue<>(cost.getComputeTaskCosts().size(), COMP_COST_PER_BLOCK_INV_COMPARATOR); double compCostPerBlockSum = 0; int numTotalBlocks = 0; for (final Cost.ComputeTaskCost computeTaskCost : cost.getComputeTaskCosts()) { final int numBlocks = computeTaskCost.getDataInfo().getNumBlocks(); final double compCostPerBlock = computeTaskCost.getComputeCost() / numBlocks; final double compCostInv = 1 / compCostPerBlock; compCostPerBlockSum += compCostPerBlock; numTotalBlocks += numBlocks; optimizedEvaluatorQueue.add(new OptimizedEvaluator( computeTaskCost.getId(), computeTaskCost.getDataInfo(), compCostInv)); } return new Tuple3<>(optimizedEvaluatorQueue, compCostPerBlockSum, numTotalBlocks); }
Source:
public boolean connect(String port) throws Exception { if (controller == null) { error("arduino is invalid"); return false; } PortConnector arduino = (PortConnector) controller; arduino.connect(port); if (!arduino.isConnected()) { error("torso arduino on port %s not connected", port); return false; } topStom.attach(controller, 27, topStom.getRest(), topStom.getVelocity()); midStom.attach(controller, 28, midStom.getRest(), midStom.getVelocity()); lowStom.attach(controller, 29, lowStom.getRest(), lowStom.getVelocity()); enableAutoEnable(true); broadcastState(); return true; }

Target:
public boolean connect(String port) throws Exception { if (controller == null) { error("arduino is invalid"); return false; } if (controller instanceof PortConnector) { PortConnector arduino = (PortConnector) controller; arduino.connect(port); if (!arduino.isConnected()) { error("torso arduino on port %s not connected", port); return false; } } topStom.attach(controller, 27, topStom.getRest(), topStom.getVelocity()); midStom.attach(controller, 28, midStom.getRest(), midStom.getVelocity()); lowStom.attach(controller, 29, lowStom.getRest(), lowStom.getVelocity()); enableAutoEnable(true); broadcastState(); return true; }
Source:
public static void initCOM() { HRESULT hres = null; if (!isComInitialized()) { hres = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED); switch (hres.intValue()) { case COMUtils.S_OK: comInitialized = true; break; case COMUtils.S_FALSE: case WinError.RPC_E_CHANGED_MODE: break; default: throw new COMException("Failed to initialize COM library.", new HRESULT(-1)); } } if (!isSecurityInitialized()) { hres = Ole32.INSTANCE.CoInitializeSecurity(null, -1, null, null, Ole32.RPC_C_AUTHN_LEVEL_DEFAULT, Ole32.RPC_C_IMP_LEVEL_IMPERSONATE, null, Ole32.EOAC_NONE, null); if (COMUtils.FAILED(hres) && hres.intValue() != WinError.RPC_E_TOO_LATE) { Ole32.INSTANCE.CoUninitialize(); throw new COMException("Failed to initialize security.", new HRESULT(-1)); } securityInitialized = true; } }

Target:
public static void initCOM() { HRESULT hres = null; if (!isComInitialized()) { hres = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED); switch (hres.intValue()) { case COMUtils.S_OK: comInitialized = true; break; case COMUtils.S_FALSE: case WinError.RPC_E_CHANGED_MODE: break; default: throw new COMException("Failed to initialize COM library.", hres); } } if (!isSecurityInitialized()) { hres = Ole32.INSTANCE.CoInitializeSecurity(null, -1, null, null, Ole32.RPC_C_AUTHN_LEVEL_DEFAULT, Ole32.RPC_C_IMP_LEVEL_IMPERSONATE, null, Ole32.EOAC_NONE, null); if (COMUtils.FAILED(hres) && hres.intValue() != WinError.RPC_E_TOO_LATE) { Ole32.INSTANCE.CoUninitialize(); throw new COMException("Failed to initialize security.", hres); } securityInitialized = true; } }