auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static String getRootPassword(Entity entity) { String password = entity.config().get(MongoDBAuthenticationMixins.ROOT_PASSWORD); if (Strings.isEmpty(password)) { LOG.debug(entity + " has no password specified for " + MongoDBAuthenticationMixins.ROOT_PASSWORD.getName() + "; using a random string"); password = Strings.makeRandomId(8); entity.sensors().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); entity.config().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); } return password; }

Target:
public static String getRootPassword(Entity entity) { String password = entity.config().get(MongoDBAuthenticationMixins.ROOT_PASSWORD); if (Strings.isEmpty(password)) { LOG.debug(entity + " has no password specified for " + MongoDBAuthenticationMixins.ROOT_PASSWORD.getName() + "; using a random string"); password = Strings.makeRandomId(16); entity.sensors().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); entity.config().set(MongoDBAuthenticationMixins.ROOT_PASSWORD, password); } return password; }
Source:
public FeedbackConstantSumQuestionDetails() { super(FeedbackQuestionType.CONSTSUM); this.numOfConstSumOptions = 0; this.constSumOptions = new ArrayList<>(); this.distributeToRecipients = false; this.pointsPerOption = false; this.points = 100; this.minPoints = 0; this.maxPoints = points; this.requireMin = false; this.requireMax = false; this.forceUnevenDistribution = false; }

Target:
public FeedbackConstantSumQuestionDetails() { super(FeedbackQuestionType.CONSTSUM); this.numOfConstSumOptions = 0; this.constSumOptions = new ArrayList<>(); this.distributeToRecipients = false; this.pointsPerOption = false; this.points = 100; this.minPointsConstraint = NO_MIN_MAX_CONSTRAINT; this.maxPointsConstraint = NO_MIN_MAX_CONSTRAINT; this.forceUnevenDistribution = false; this.distributePointsFor = FeedbackConstantSumDistributePointsType.NONE.getDisplayedOption(); }
Source:
private void openLogin() { Intent i = new Intent(this, LoginActivity.class); String server_url = getSharedPreferences(LoginActivity.Prefs_name,MODE_PRIVATE).getString(LoginActivity.Prefs_server,null); i.putExtra("server_url",server_url); startActivity(i); finish(); }

Target:
private void openLogin() { Intent i = new Intent(this, LoginActivity.class); i.putExtra("server_url",server_url); startActivity(i); finish(); }
Source:
private static ProcessMetadata processSampleInformation() { XPathExpression[] expr = RunProcessor.compileXPath(" return (document, dto) -> { String well = (String) expr[0].evaluate(document, XPathConstants.STRING); String name = (String) expr[1].evaluate(document, XPathConstants.STRING); if (LimsUtils.isStringBlankOrNull(name) || LimsUtils.isStringBlankOrNull(well)) { return; } Map<String, String> poolInfo = dto.getPoolNames(); if (poolInfo == null) { poolInfo = new HashMap<>(); dto.setPoolNames(poolInfo); } else if (poolInfo.containsKey(well)) { name = ""; } poolInfo.put(well, name); }; }

Target:
private static ProcessMetadata processSampleInformation() { XPathExpression[] expr = RunProcessor.compileXPath(" return (document, dto) -> { String well = (String) expr[0].evaluate(document, XPathConstants.STRING); String name = (String) expr[1].evaluate(document, XPathConstants.STRING); if (LimsUtils.isStringBlankOrNull(name) || LimsUtils.isStringBlankOrNull(well)) { return; } Map<String, String> poolInfo = dto.getPoolNames(); if (poolInfo == null) { poolInfo = new HashMap<>(); dto.setPoolNames(poolInfo); } else if (poolInfo.containsKey(well)) { log.error(String.format("Multiple pools in well %s on run %s; abandoing automatic pool assignment", well, dto.getRunAlias())); name = ""; } poolInfo.put(well, name); }; }
Source:
public void addBinding(final Binding binding) { try { if (logger.isTraceEnabled()) { logger.trace("addBinding(" + binding + ") being called"); } if (binding.isExclusive()) { if (!exclusiveBindings.contains(binding)) { exclusiveBindings.add(binding); } } else { SimpleString routingName = binding.getRoutingName(); List<Binding> bindings = routingNameBindingMap.get(routingName); if (bindings == null) { bindings = new CopyOnWriteArrayList<>(); List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings); if (oldBindings != null) { bindings = oldBindings; } } if (!bindings.contains(binding)) { bindings.add(binding); } } bindingsIdMap.put(binding.getID(), binding); bindingsNameMap.put(binding.getUniqueName(), binding); if (logger.isTraceEnabled()) { logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings()); } } finally { updated(); } }

Target:
public void addBinding(final Binding binding) { try { if (logger.isTraceEnabled()) { logger.trace("addBinding(" + binding + ") being called"); } if (binding.isExclusive()) { exclusiveBindings.add(binding); } else { SimpleString routingName = binding.getRoutingName(); List<Binding> bindings = routingNameBindingMap.get(routingName); if (bindings == null) { bindings = new CopyOnWriteArrayList<>(); List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings); if (oldBindings != null) { bindings = oldBindings; } } if (!bindings.contains(binding)) { bindings.add(binding); } } bindingsIdMap.put(binding.getID(), binding); bindingsNameMap.put(binding.getUniqueName(), binding); if (logger.isTraceEnabled()) { logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings()); } } finally { updated(); } }
Source:
public boolean isConnectedToWifi() { if (androidVersion.isMarshmallowOrHigher()) { return connectedToNetworkTypeForMarshmallow(ConnectivityManager.TYPE_WIFI); } else { NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return networkInfo != null && networkInfo.isConnected(); } }

Target:
public boolean isConnectedToWifi() { return isConnectedTo(ConnectivityManager.TYPE_WIFI); }
Source:
private static boolean isEqualsMethod(MethodInvocationTree syntaxNode) { if (syntaxNode.arguments().size() == 1) { final ExpressionTree methodSelect = syntaxNode.methodSelect(); if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree expression = (MemberSelectExpressionTree) methodSelect; return "equals".equals(expression.identifier().name()); } } return false; }

Target:
private static boolean isEqualsMethod(MethodInvocationTree syntaxNode) { if (syntaxNode.arguments().size() == 1) { ExpressionTree methodSelect = syntaxNode.methodSelect(); if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree expression = (MemberSelectExpressionTree) methodSelect; if ("equals".equals(expression.identifier().name()) && syntaxNode.symbol().isMethodSymbol()) { Symbol.MethodSymbol symbol = (Symbol.MethodSymbol) syntaxNode.symbol(); return symbol.parameterTypes().get(0).is("java.lang.Object"); } } } return false; }
Source:
public boolean destroyNetworkRulesForNic(final Connect conn, final String vmName, final NicTO nic) { if (!_canBridgeFirewall) { return false; } final List<String> nicSecIps = nic.getNicSecIps(); String secIpsStr; final StringBuilder sb = new StringBuilder(); if (nicSecIps != null) { for (final String ip : nicSecIps) { sb.append(ip).append(";"); } secIpsStr = sb.toString(); } else { secIpsStr = "0;"; } final List<InterfaceDef> intfs = getInterfaces(conn, vmName); if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } final InterfaceDef intf = intfs.get(nic.getDeviceId()); final String brname = intf.getBrName(); final String vif = intf.getDevName(); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("destroy_network_rules_for_vm"); cmd.add("--vmname", vmName); if (nic.getIp() != null) { cmd.add("--vmip", nic.getIp()); } cmd.add("--vmmac", nic.getMac()); cmd.add("--vif", vif); cmd.add("--nicsecips", secIpsStr); final String result = cmd.execute(); if (result != null) { return false; } return true; }

Target:
public boolean destroyNetworkRulesForNic(final Connect conn, final String vmName, final NicTO nic) { if (!_canBridgeFirewall) { return false; } final List<String> nicSecIps = nic.getNicSecIps(); String secIpsStr; final StringBuilder sb = new StringBuilder(); if (nicSecIps != null) { for (final String ip : nicSecIps) { sb.append(ip).append(SecurityGroupRulesCmd.RULE_COMMAND_SEPARATOR); } secIpsStr = sb.toString(); } else { secIpsStr = "0" + SecurityGroupRulesCmd.RULE_COMMAND_SEPARATOR; } final List<InterfaceDef> intfs = getInterfaces(conn, vmName); if (intfs.size() == 0 || intfs.size() < nic.getDeviceId()) { return false; } final InterfaceDef intf = intfs.get(nic.getDeviceId()); final String brname = intf.getBrName(); final String vif = intf.getDevName(); final Script cmd = new Script(_securityGroupPath, _timeout, s_logger); cmd.add("destroy_network_rules_for_vm"); cmd.add("--vmname", vmName); if (nic.getIp() != null) { cmd.add("--vmip", nic.getIp()); } cmd.add("--vmmac", nic.getMac()); cmd.add("--vif", vif); cmd.add("--nicsecips", secIpsStr); final String result = cmd.execute(); if (result != null) { return false; } return true; }
Source:
protected void checkMultipleEditors() { fVM= ScrapbookLauncher.getDefault().getDebugTarget(getFile()); if (fVM != null) { DebugPlugin.getDefault().addDebugEventFilter(this); try { for (IThread iThread : fVM.getThreads()) { if (iThread.isSuspended()) { iThread.resume(); } } } catch (DebugException de) { JDIDebugUIPlugin.log(de); } } }

Target:
protected void checkMultipleEditors() { fVM= ScrapbookLauncher.getDefault().getDebugTarget(getFile()); if (fVM != null) { DebugPlugin.getDefault().addDebugEventFilter(this); try { for (IThread thread : fVM.getThreads()) { if (thread.isSuspended()) { thread.resume(); } } } catch (DebugException de) { JDIDebugUIPlugin.log(de); } } }
Source:
protected ServletBinder register(ServletBinder binder) { if (resolver == null) throw new IllegalStateException(HttpServerText.get().noResolverAvailable); binder = binder.through(new WWWAuthenticationFilter(realmName)); binder = binder.through(new NoCacheFilter()); binder = binder.through(new RepositoryFilter(resolver)); return binder; }

Target:
protected ServletBinder register(ServletBinder binder) { if (resolver == null) throw new IllegalStateException(HttpServerText.get().noResolverAvailable); binder = binder.through(new WWWAuthenticateFilter(authMethod, realmName)); binder = binder.through(new NoCacheFilter()); binder = binder.through(new RepositoryFilter(resolver)); return binder; }
Source:
public void cleanup() throws IOException { getMetastoreClient(TEST_DB_NAME).dropDatabase(TEST_DB_NAME); deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); }

Target:
public void cleanup() throws IOException { try { getMetastoreClient(TEST_DB_NAME).dropDatabase(TEST_DB_NAME); } finally { deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); } }
Source:
public void testGetContentWithSyntaxErrors() throws IOException { final WDLHandler wdlHandler = new WDLHandler(); final File wdlFile = new File(ResourceHelpers.resourceFilePath("brokenWDL.wdl")); final Set<SourceFile> emptySet = Collections.emptySet(); final ToolDAO toolDAO = Mockito.mock(ToolDAO.class); when(toolDAO.findAllByPath(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(null); try { wdlHandler.getContent("/brokenWDL.wdl", FileUtils.readFileToString(wdlFile, StandardCharsets.UTF_8), emptySet, LanguageHandlerInterface.Type.TOOLS, toolDAO); } catch (CustomWebApplicationException e) { Assert.assertEquals(e.getResponse().getStatus(), 400); Assert.assertTrue("Should contain parsing error statement, found: " + e.errorMessage, e.errorMessage.contains(WDLHandler.WDL_PARSE_ERROR)); } }

Target:
public void testGetContentWithSyntaxErrors() throws IOException { final WDLHandler wdlHandler = new WDLHandler(); final File wdlFile = new File(ResourceHelpers.resourceFilePath("brokenWDL.wdl")); final Set<SourceFile> emptySet = Collections.emptySet(); final ToolDAO toolDAO = Mockito.mock(ToolDAO.class); when(toolDAO.findAllByPath(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(null); try { wdlHandler.getContent("/brokenWDL.wdl", FileUtils.readFileToString(wdlFile, StandardCharsets.UTF_8), emptySet, LanguageHandlerInterface.Type.TOOLS, toolDAO); Assert.fail("Expected parsing error"); } catch (CustomWebApplicationException e) { Assert.assertEquals(400, e.getResponse().getStatus()); assertThat(e.getErrorMessage()).contains(WDLHandler.WDL_PARSE_ERROR); } }
Source:
private ContactCache() { accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build( new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() { @Override public Map<String, List<BlackboardArtifact>> load(String key) { try { return buildMap(); } catch (SQLException | TskCoreException ex) { logger.log(Level.WARNING, "Failed to build account to contact map", ex); } return new HashMap<>(); } }); PropertyChangeListener ingestListener = pce -> { String eventType = pce.getPropertyName(); if (eventType.equals(DATA_ADDED.toString())) { ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue(); if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT.getTypeID()) { invalidateCache(); } } }; IngestManager.getInstance().addIngestModuleEventListener(EnumSet.of(DATA_ADDED), ingestListener); }

Target:
private ContactCache() { accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build( new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() { @Override public Map<String, List<BlackboardArtifact>> load(String key) { try { return buildMap(); } catch (SQLException | TskCoreException ex) { logger.log(Level.WARNING, "Failed to build account to contact map", ex); } return new HashMap<>(); } }); PropertyChangeListener ingestListener = pce -> { String eventType = pce.getPropertyName(); if (eventType.equals(DATA_ADDED.toString())) { ModuleDataEvent eventData = (ModuleDataEvent) pce.getOldValue(); if (eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT.getTypeID()) { invalidateCache(); } } }; Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent event) -> { if (event.getNewValue() == null) { invalidateCache(); } }); IngestManager.getInstance().addIngestModuleEventListener(EnumSet.of(DATA_ADDED), ingestListener); }
Source:
private void handleCheckpointSaved( CheckpointManager.StatefulConsistentCheckpointSaved message) { LOG.info("Received a StatefulCheckpointSaved message:with checkpoint id: " + message.getConsistentCheckpoint().getCheckpointId()); InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder() .setStatefulCheckpointSaved(message) .build(); inControlQueue.offer(instanceControlMsg); }

Target:
private void handleCheckpointSaved( CheckpointManager.StatefulConsistentCheckpointSaved message) { LOG.info("Received a StatefulCheckpointSaved message with checkpoint id: " + message.getConsistentCheckpoint().getCheckpointId()); InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder() .setStatefulCheckpointSaved(message) .build(); inControlQueue.offer(instanceControlMsg); }
Source:
public GrillClient(GrillClientConfig conf, String username, String password) { this.conf = conf; conf.setUser(username); this.password = password; try { String user = ShimLoader.getHadoopShims().getUGIForConf(conf).getUserName(); this.conf.set("grill.session.cluster.user", user); } catch (LoginException e) { LOG.error(e); } catch (IOException e) { LOG.error(e); } connectToGrillServer(); statement = new GrillStatement(conn); }

Target:
public GrillClient(GrillClientConfig conf, String username, String password) { this.conf = conf; conf.setUser(username); this.password = password; if(this.conf.get(GrillClientConfig.GRILL_SESSION_CLUSTER_USER) == null) { this.conf.set(GrillClientConfig.GRILL_SESSION_CLUSTER_USER, System.getProperty("user.name")); } connectToGrillServer(); statement = new GrillStatement(conn); }
Source:
public void testShift_JISEncoding() throws Exception { HTTPArgument arg; arg = new HTTPArgument("name.?", "value_ here", false, "Shift_JIS"); assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); arg = new HTTPArgument("name.?", "value_ here", true, "Shift_JIS"); assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); arg = new HTTPArgument("name.%3F", "value_+here", true, "Shift_JIS"); assertEquals("name.?", arg.getName()); assertEquals("value_ here", arg.getValue()); assertEquals("name.%3F", arg.getEncodedName()); assertEquals("value_+here", arg.getEncodedValue()); arg.setAlwaysEncoded(false); assertEquals("name.?", arg.getEncodedName()); assertEquals("value_ here", arg.getEncodedValue()); arg = new HTTPArgument("", "\00\01\07", "", false, "Shift_JIS"); arg.setAlwaysEncoded(false); assertEquals("", arg.getEncodedName()); assertEquals("\00\01\07", arg.getEncodedValue()); }

Target:
public void testShift_JISEncoding() throws Exception { testEncodings("Shift_JIS"); }
Source:
public ColoredDataProcessor() { super(stack -> ColorUtil.getItemStackColor(stack).isPresent(), Keys.COLOR); }

Target:
public ColoredDataProcessor() { super(ColorUtil::hasColor, Keys.COLOR); }
Source:
String getViewFullName(View view) { String n = view.getOwnerItemGroup().getFullName(); if(n.length()==0) return view.getViewName(); else return n+'/'+ view.getViewName(); }

Target:
String getViewFullName(View view) { StringBuilder sb = new StringBuilder(); sb.append(view.getOwnerItemGroup().getFullName()); if(sb.length()==0) { return view.getViewName(); } else { sb.append("/" + view.getViewName()); return sb.toString(); } }
Source:
private void promptToRefreshAll() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_prompt_refresh_all_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { markAllPagesOutdated(); } }); builder.setNegativeButton(R.string.no, null); builder.create().show(); }

Target:
private void promptToRefreshAll() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_prompt_refresh_all_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { refreshAll(); } }); builder.setNegativeButton(R.string.no, null); builder.create().show(); }
Source:
public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { } catch (Exception e) { e.printStackTrace(); } try { } catch (Exception e) { e.printStackTrace(); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); return item; }

Target:
public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { Collection c = obj.getOwningCollection(); if (c != null) { item.setOwningCollection(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting owning collection for item"+item.getHandle(), e); } try { Collection c = obj.getTemplateItemOf(); if (c != null) { item.setTemplateItemOf(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting template item of for item "+item.getHandle(), e); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); return item; }
Source:
void init(Drawable drawable, GCData data, long gdkGC) { if (GTK.GTK3) { if (data.foregroundRGBA != null) data.state &= ~FOREGROUND; if (data.backgroundRGBA != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } else { if (data.foreground != null) data.state &= ~FOREGROUND; if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } if (data.font != null) data.state &= ~FONT; Image image = data.image; if (image != null) { image.memGC = this; if (image.transparentPixel != -1) image.destroyMask(); } this.drawable = drawable; this.data = data; handle = gdkGC; long cairo = data.cairo = handle; Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET); setClipping(data.clipRgn); if ((data.style & SWT.MIRRORED) != 0) { initCairo(); if (GTK.GTK_VERSION >= OS.VERSION (3, 14, 0)) { int[] w = new int[1], h = new int[1]; getSize(w, h); Cairo.cairo_translate(cairo, w[0], 0); Cairo.cairo_scale(cairo, -1.0, 1.0); } else { Cairo.cairo_set_matrix(data.cairo, identity()); } } if (cairoTransformationMatrix == null) cairoTransformationMatrix = new double[6]; Cairo.cairo_get_matrix(data.cairo, cairoTransformationMatrix); clipping = getClipping(); }

Target:
void init(Drawable drawable, GCData data, long gdkGC) { if (GTK.GTK3) { if (data.foregroundRGBA != null) data.state &= ~FOREGROUND; if (data.backgroundRGBA != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } else { if (data.foreground != null) data.state &= ~FOREGROUND; if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG); } if (data.font != null) data.state &= ~FONT; Image image = data.image; if (image != null) { image.memGC = this; if (image.transparentPixel != -1) image.destroyMask(); } this.drawable = drawable; this.data = data; handle = gdkGC; long cairo = data.cairo = handle; Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET); setClipping(data.clipRgn); initCairo(); if ((data.style & SWT.MIRRORED) != 0) { if (GTK.GTK_VERSION >= OS.VERSION (3, 14, 0)) { int[] w = new int[1], h = new int[1]; getSize(w, h); Cairo.cairo_translate(cairo, w[0], 0); Cairo.cairo_scale(cairo, -1.0, 1.0); } else { Cairo.cairo_set_matrix(data.cairo, identity()); } } if (cairoTransformationMatrix == null) cairoTransformationMatrix = new double[6]; Cairo.cairo_get_matrix(data.cairo, cairoTransformationMatrix); clipping = getClipping(); }
Source:
public void customize() { Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort())); newScript(CUSTOMIZING) .body.append( String.format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()), "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq", "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq", "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml" ) .execute(); String configFileContents = processTemplate(getTemplateConfigurationUrl()); String destinationConfigFile = format("%s/conf/activemq.xml", getRunDir()); getMachine().copyTo(new ByteArrayInputStream(configFileContents.getBytes()), destinationConfigFile); }

Target:
public void customize() { Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort())); newScript(CUSTOMIZING) .body.append( format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()), "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq", "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq", "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml" ) .execute(); String destinationConfigFile = Os.mergePathsUnix(getRunDir(), "conf/activemq.xml"); copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile); }
Source:
public void create() throws EntityAlreadyExistsException { EntityRef<E, C> ref = getEntityRef(); try { while (true) { ref.create(configuration); try { ref.fetchEntity().close(); return; } catch (EntityNotFoundException e) { } } } catch (EntityNotProvidedException e) { LOGGER.error("Unable to create clustered tier manager for id {}", entityIdentifier, e); throw new AssertionError(e); } catch (EntityVersionMismatchException e) { LOGGER.error("Unable to create clustered tier manager for id {}", entityIdentifier, e); throw new AssertionError(e); } }

Target:
public void create() throws EntityAlreadyExistsException { EntityRef<E, C> ref = getEntityRef(); try { while (true) { ref.create(configuration); try { ref.fetchEntity().close(); return; } catch (EntityNotFoundException e) { } } } catch (EntityNotProvidedException e) { LOGGER.error("Unable to create entity for id {}", entityType.getName(), entityIdentifier, e); throw new AssertionError(e); } catch (EntityVersionMismatchException e) { LOGGER.error("Unable to create entity for id {}", entityType.getName(), entityIdentifier, e); throw new AssertionError(e); } }
Source:
public void read(BitBuffer input) { final long longNegBit = 0x0000000080000000L; int align = (int) declaration.getAlignment(); int pos = input.position() + ((align-(input.position() % align))%align); input.position(pos); boolean signed = declaration.isSigned(); int length = declaration.getLength(); long bits = 0; if (length == 64) { long low = input.getInt(32, false); low = low & 0x00000000FFFFFFFFL; long high = input.getInt(32, false); high = high & 0x00000000FFFFFFFFL; if (this.declaration.getByteOrder() != ByteOrder.BIG_ENDIAN) { bits = (high << 32) | low; } else { bits = (low << 32) | high; } } else { ByteOrder byteOrder = input.getByteOrder(); if ( (this.declaration.getByteOrder() != null) && (this.declaration.getByteOrder() != input.getByteOrder()) ) { input.setByteOrder(this.declaration.getByteOrder()); } bits = input.getInt(length, signed); bits = bits & 0x00000000FFFFFFFFL; if( (longNegBit == (bits & longNegBit)) && signed) { bits |= 0xffffffff00000000L; } if (byteOrder != input.getByteOrder()) { input.setByteOrder(byteOrder); } } value = bits; }

Target:
public void read(BitBuffer input) { final long longNegBit = 0x0000000080000000L; int align = (int) declaration.getAlignment(); int pos = input.position() + ((align-(input.position() % align))%align); input.position(pos); boolean signed = declaration.isSigned(); int length = declaration.getLength(); long bits = 0; ByteOrder byteOrder = input.getByteOrder(); if ( (this.declaration.getByteOrder() != null) && (this.declaration.getByteOrder() != input.getByteOrder()) ) { input.setByteOrder(this.declaration.getByteOrder()); } if (length == 64) { long low = input.getInt(32, false); low = low & 0x00000000FFFFFFFFL; long high = input.getInt(32, false); high = high & 0x00000000FFFFFFFFL; if (this.declaration.getByteOrder() != ByteOrder.BIG_ENDIAN) { bits = (high << 32) | low; } else { bits = (low << 32) | high; } } else { bits = input.getInt(length, signed); bits = bits & 0x00000000FFFFFFFFL; if( (longNegBit == (bits & longNegBit)) && signed) { bits |= 0xffffffff00000000L; } } if (byteOrder != input.getByteOrder()) { input.setByteOrder(byteOrder); } value = bits; }
Source:
public SampleRecord(long rowid, Random rand, Date tsNotNull) { this.rowid = rowid; this.rowid_group = (byte)((rowid % 255) - 127); this.type_null_tinyint = nextTinyint(rand, true); this.type_not_null_tinyint = nextTinyint(rand); this.type_null_smallint = nextSmallint(rand, true); this.type_not_null_smallint = nextSmallint(rand); this.type_null_integer = nextInteger(rand, true); this.type_not_null_integer = nextInteger(rand); this.type_null_bigint = nextBigint(rand, true); this.type_not_null_bigint = nextBigint(rand); this.type_null_timestamp = nextTimestamp(rand, true); this.type_not_null_timestamp = nextTimestamp(rand); this.type_null_float = nextFloat(rand, true); this.type_not_null_float = tsNotNull; this.type_null_decimal = nextDecimal(rand, true); this.type_not_null_decimal = nextDecimal(rand); this.type_null_varchar25 = nextVarchar(rand, true, 1, 25); this.type_not_null_varchar25 = nextVarchar(rand, 1, 25); this.type_null_varchar128 = nextVarchar(rand, true, 25, 128); this.type_not_null_varchar128 = nextVarchar(rand, 25, 128); this.type_null_varchar1024 = nextVarchar(rand, true, 128, 1024); this.type_not_null_varchar1024 = nextVarchar(rand, 128, 1024); }

Target:
public SampleRecord(long rowid, Random rand, Date tsNotNull) { this.rowid = rowid; this.rowid_group = (byte)((rowid % 255) - 127); this.type_null_tinyint = nextTinyint(rand, true); this.type_not_null_tinyint = nextTinyint(rand); this.type_null_smallint = nextSmallint(rand, true); this.type_not_null_smallint = nextSmallint(rand); this.type_null_integer = nextInteger(rand, true); this.type_not_null_integer = nextInteger(rand); this.type_null_bigint = nextBigint(rand, true); this.type_not_null_bigint = nextBigint(rand); this.type_null_timestamp = nextTimestamp(rand, true); this.type_not_null_timestamp = tsNotNull; this.type_null_float = nextFloat(rand, true); this.type_not_null_float = nextFloat(rand); this.type_null_decimal = nextDecimal(rand, true); this.type_not_null_decimal = nextDecimal(rand); this.type_null_varchar25 = nextVarchar(rand, true, 1, 25); this.type_not_null_varchar25 = nextVarchar(rand, 1, 25); this.type_null_varchar128 = nextVarchar(rand, true, 25, 128); this.type_not_null_varchar128 = nextVarchar(rand, 25, 128); this.type_null_varchar1024 = nextVarchar(rand, true, 128, 1024); this.type_not_null_varchar1024 = nextVarchar(rand, 128, 1024); }
Source:
public RevocationOp(PoolCurator poolCurator, List<Pool> pools) { entitlementsToRevoke = new HashSet<Entitlement>(); entitlementsToAdjust = new HashMap<Entitlement, Long>(); sharedPools = new HashMap<Pool, List<Pool>>(); this.poolCurator = poolCurator; this.pools = pools; }

Target:
public RevocationOp(PoolCurator poolCurator, List<Pool> pools) { entitlementsToRevoke = new HashSet<Entitlement>(); shareEntitlementsToAdjust = new HashMap<Entitlement, Long>(); sharedPools = new HashMap<Pool, List<Pool>>(); poolNewConsumed = new HashMap<Pool, Long>(); this.poolCurator = poolCurator; this.pools = pools; }
Source:
protected ComboViewer createComboViewer(final Composite parent, final EEnum eEnum) { final CCombo combo = new CCombo(parent, SWT.BORDER); combo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_CYAN)); combo.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event argEvent) { combo.setText(combo.getText()); } }); combo.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { combo.clearSelection(); } @Override public void focusGained(FocusEvent e) { } }); combo.setEditable(true); final MatchItemComboViewer viewer = new MatchItemComboViewer(combo) { @Override public void onEnter(int selectedIndex) { if (!isEmptyBuffer() && selectedIndex > -1) { final String closestMatch = getCCombo().getItems()[selectedIndex]; final Optional<EEnumLiteral> findLiteral = findLiteral(eEnum.getELiterals(), closestMatch); if (findLiteral.isPresent()) { setSelection(new StructuredSelection(findLiteral.get().getInstance())); } } else { setClosestMatch(getCCombo().getText()); } combo.clearSelection(); } }; return viewer; }

Target:
protected ComboViewer createComboViewer(final Composite parent, final EEnum eEnum) { final CCombo combo = new CCombo(parent, SWT.BORDER); combo.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event argEvent) { combo.setText(combo.getText()); } }); combo.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { combo.clearSelection(); } @Override public void focusGained(FocusEvent e) { } }); combo.setEditable(true); final MatchItemComboViewer viewer = new MatchItemComboViewer(combo) { @Override public void onEnter(int selectedIndex) { if (!isEmptyBuffer() && selectedIndex > -1) { final String closestMatch = getCCombo().getItems()[selectedIndex]; final Optional<EEnumLiteral> findLiteral = findLiteral(eEnum.getELiterals(), closestMatch); if (findLiteral.isPresent()) { setSelection(new StructuredSelection(findLiteral.get().getInstance())); } } else { setClosestMatch(getCCombo().getText()); } combo.clearSelection(); } }; return viewer; }
Source:
public static WebAPICommand build(final String commandName, final ParameterSet options) throws CommandSpecException { if (!MAPPINGS.containsKey(commandName)) { throw new CommandSpecException("'" + commandName + "' is not a geogig command"); } WebAPICommand command = MAPPINGS.get(commandName).apply(options); if (command instanceof AbstractWebAPICommand) { ((AbstractWebAPICommand) command).setTransactionId(options.getFirstValue( "transactionId", null)); } return command; }

Target:
public static WebAPICommand build(final String commandName, final ParameterSet options) throws CommandSpecException { if (!MAPPINGS.containsKey(commandName)) { throw new CommandSpecException("'" + commandName + "' is not a geogig command"); } WebAPICommand command = MAPPINGS.get(commandName).apply(options); return command; }
Source:
private boolean upgradeThreeFour(SQLiteDatabase db) { db.beginTransaction(); try { db.execSQL("CREATE INDEX global_index_id ON " + CommCareApp.GLOBAL_STORAGE_TABLE_KEY + " ( " + Resource.META_INDEX_PARENT_GUID + " )"); db.execSQL("CREATE INDEX upgrade_index_id ON " + CommCareApp.UPGRADE_STORAGE_TABLE_KEY + " ( " + Resource.META_INDEX_PARENT_GUID + " )"); db.execSQL("CREATE INDEX recovery_index_id ON " + CommCareApp.RECOVERY_STORAGE_TABLE_KEY + " ( " + Resource.META_INDEX_PARENT_GUID + " )"); db.setTransactionSuccessful(); return true; } finally { db.endTransaction(); } }

Target:
private boolean upgradeThreeFour(SQLiteDatabase db) { db.beginTransaction(); try { db.execSQL("CREATE INDEX global_index_id ON GLOBAL_RESOURCE_TABLE ( PGUID )"); db.execSQL("CREATE INDEX upgrade_index_id ON UPGRADE_RESOURCE_TABLE ( PGUID )"); db.execSQL("CREATE INDEX recovery_index_id ON RECOVERY_RESOURCE_TABLE ( PGUID )"); db.setTransactionSuccessful(); return true; } finally { db.endTransaction(); } }
Source:
public void buildFormStructure_shouldCombineConfigSectionsIntoOne() throws Exception { ObjectMapper mapper = new ObjectMapper(); List<AppDescriptor> appDescriptors = mapper.readValue(getClass().getClassLoader().getResourceAsStream("registration_app.json"), new TypeReference<List<AppDescriptor>>() {}); AppDescriptor appDescriptor = appDescriptors.get(0); List<String> questionIds = new ArrayList<String>(); questionIds.add("personAddress"); questionIds.add("phoneNumber"); questionIds.add("fathersDetails"); questionIds.add("mothersDetails"); questionIds.add("insuranceDetails"); questionIds.add("triageVitals"); NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(appDescriptor, true); Map<String, Section> sections = formStructure.getSections(); assertEquals(1, sections.size()); Section combinedSection = sections.get(RegisterPatientFormBuilder.DEMOGRAPHICS_SECTION_ID); assertNotNull(combinedSection); for (Question question : combinedSection.getQuestions()) { assertTrue(questionIds.contains(question.getId())); } }

Target:
public void buildFormStructure_shouldCombineConfigSectionsIntoOne() throws Exception { ObjectMapper mapper = new ObjectMapper(); List<AppDescriptor> appDescriptors = mapper.readValue(getClass().getClassLoader().getResourceAsStream("registration_app.json"), new TypeReference<List<AppDescriptor>>() {}); AppDescriptor appDescriptor = appDescriptors.get(0); List<String> questionIds = new ArrayList<String>(); Iterator<JsonNode> sectionIt = appDescriptor.getConfig().get("sections").getElements(); while(sectionIt.hasNext()) { Iterator<JsonNode> questionIt = sectionIt.next().get("questions").getElements(); while(questionIt.hasNext()) { questionIds.add(questionIt.next().get("id").getTextValue()); } } NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(appDescriptor, true); Map<String, Section> sections = formStructure.getSections(); assertEquals(1, sections.size()); Section combinedSection = sections.get(RegisterPatientFormBuilder.DEMOGRAPHICS_SECTION_ID); assertNotNull(combinedSection); for (Question question : combinedSection.getQuestions()) { assertTrue(questionIds.contains(question.getId())); } }
Source:
public void buildActionsShouldReturnTwoActionsForTwoConfigs() { List<ActionEventRequest> eventRequests = importFormActionBuilder.buildActions(); assertEquals(2, eventRequests.size()); }

Target:
public void buildActionsShouldReturnTwoActionsForTwoConfigs() { List<ActionEventRequest> eventRequests = importFormActionBuilder.buildActions(); assertEquals(2, eventRequests.size()); String firstConfigName = configs.getConfigs().get(0).getName(); String secondConfigName = configs.getConfigs().get(1).getName(); String expectedDisplayNameForFirstConfig = "Import Forms [" + firstConfigName + "]"; String expectedSubjectForFirstConfig = EventSubjects.IMPORT_FORMS + "." + firstConfigName; String expectedDisplayNameForSecondConfig = "Import Forms [" + secondConfigName + "]"; String expectedSubjectForSecondConfig = EventSubjects.IMPORT_FORMS + "." + secondConfigName; ActionEventRequest eventRequestForFirsConfig = eventRequests.get(0); ActionEventRequest eventRequestForSecondConfig = eventRequests.get(1); assertEquals(expectedDisplayNameForFirstConfig, eventRequestForFirsConfig.getDisplayName()); assertEquals(expectedSubjectForFirstConfig, eventRequestForFirsConfig.getSubject()); assertEquals(expectedDisplayNameForSecondConfig, eventRequestForSecondConfig.getDisplayName()); assertEquals(expectedSubjectForSecondConfig, eventRequestForSecondConfig.getSubject()); }
Source:
public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable( DirectedGraph<V, E> graph) { DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph; Map<Pair<V, V>, int[]> shortestDistances = new HashMap<>(); for (DefaultDirectedGraph.VertexInfo<V, E> arc : graph1.vertexMap.values()) { for (E edge : arc.outEdges) { final V source = graph1.source(edge); final V target = graph1.target(edge); shortestDistances.put(Pair.of(source, target), new int[] {1}); } } while (true) { final List<Pair<V, V>> previous = ImmutableList.copyOf(shortestDistances.keySet()); boolean changeCount = false; for (E edge : graph.edgeSet()) { for (Pair<V, V> edge2 : previous) { if (edge.target.equals(edge2.left)) { final Pair<V, V> key = Pair.of(graph1.source(edge), edge2.right); int[] bestDistance = shortestDistances.get(key); int[] arc2Distance = shortestDistances.get(edge2); if ((bestDistance == null) || (bestDistance[0] > (arc2Distance[0] + 1))) { shortestDistances.put(key, new int[] {arc2Distance[0] + 1}); changeCount = true; } } } } if (!changeCount) { break; } } return new FrozenGraph<>(graph1, shortestDistances); }

Target:
public static <V, E extends DefaultEdge> FrozenGraph<V, E> makeImmutable( DirectedGraph<V, E> graph) { DefaultDirectedGraph<V, E> graph1 = (DefaultDirectedGraph<V, E>) graph; Map<Pair<V, V>, int[]> shortestDistances = new HashMap<>(); for (DefaultDirectedGraph.VertexInfo<V, E> arc : graph1.vertexMap.values()) { for (E edge : arc.outEdges) { final V source = graph1.source(edge); final V target = graph1.target(edge); shortestDistances.put(Pair.of(source, target), new int[] {1}); } } while (true) { final List<Pair<V, V>> previous = ImmutableList.copyOf(shortestDistances.keySet()); boolean changed = false; for (E edge : graph.edgeSet()) { for (Pair<V, V> edge2 : previous) { if (edge.target.equals(edge2.left)) { final Pair<V, V> key = Pair.of(graph1.source(edge), edge2.right); int[] bestDistance = shortestDistances.get(key); int[] arc2Distance = shortestDistances.get(edge2); if ((bestDistance == null) || (bestDistance[0] > (arc2Distance[0] + 1))) { shortestDistances.put(key, new int[] {arc2Distance[0] + 1}); changed = true; } } } } if (!changed) { break; } } return new FrozenGraph<>(graph1, shortestDistances); }
Source:
private void performGo(boolean inNewTab) { String memorySpace = null; if (fGotoMemorySpaceControl.isVisible()) { memorySpace = fGotoMemorySpaceControl.getText(); if (memorySpace.equals(NA_MEMORY_SPACE_ID)) { memorySpace = null; } assert (memorySpace == null) || (memorySpace.length() > 0); } String expression = fGotoAddressBar.getExpressionText(); if (expression.length() > 0) { final CTabFolder activeFolder = (CTabFolder) fStackLayout.topControl; Object context = null; if (activeFolder != null) { context = activeFolder.getData(KEY_CONTEXT); } fGotoAddressBar.addExpressionToHistory(context, expression, memorySpace); try { performGo(inNewTab, expression, memorySpace); } catch (DebugException e) { } } }

Target:
private void performGo(boolean inNewTab) { String memorySpace = null; if (fGotoMemorySpaceControl.isVisible()) { memorySpace = fGotoMemorySpaceControl.getText(); if (memorySpace.equals(NA_MEMORY_SPACE_ID)) { memorySpace = null; } assert (memorySpace == null) || (memorySpace.length() > 0); } String expression = fGotoAddressBar.getExpressionText(); if (expression.length() > 0) { final CTabFolder activeFolder = (CTabFolder) fStackLayout.topControl; Object context = null; if (activeFolder != null) { context = activeFolder.getData(KEY_CONTEXT); } fGotoAddressBar.addExpressionToHistory(context, expression, memorySpace); performGo(inNewTab, expression, memorySpace); } }
Source:
protected void doc(Class c) throws IOException { open("tr class='TableRowColor'"); open("td"); around("span class='modifiers'",getModifiers(c)); close("td"); open("td"); link(c.getType()); tag("br"); around("span class='doc'", getDoc(c)); close("td"); close("tr"); }

Target:
private void doc(Class c) throws IOException { open("tr class='TableRowColor'"); open("td"); around("span class='modifiers'", getModifiers(c)); close("td"); open("td"); link(c.getType()); tag("br"); around("span class='doc'", getDoc(c)); close("td"); close("tr"); }
Source:
private String[] getStringValuesFromDatabase(String sqlStmt, Object... params) throws UserStoreException { if(log.isDebugEnabled()) { log.debug("Execuring Query: " + sqlStmt); for (int i = 0; i < params.length; i++) { Object param = params[i]; log.debug("Input value: " + param); } } String[] values = new String[0]; Connection dbConnection = null; PreparedStatement prepStmt = null; ResultSet rs = null; try { dbConnection = getDBConnection(); values = DatabaseUtil.getStringValuesFromDatabase(dbConnection, sqlStmt, params); } catch (SQLException e) { String errorMessage = "Error Occurred Using sql :"+sqlStmt; if(log.isDebugEnabled()){ log.debug(errorMessage,e); } throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt); } return values; }

Target:
private String[] getStringValuesFromDatabase(String sqlStmt, Object... params) throws UserStoreException { if(log.isDebugEnabled()) { log.debug("Executing Query: " + sqlStmt); for (int i = 0; i < params.length; i++) { Object param = params[i]; log.debug("Input value: " + param); } } String[] values = new String[0]; Connection dbConnection = null; PreparedStatement prepStmt = null; ResultSet rs = null; try { dbConnection = getDBConnection(); values = DatabaseUtil.getStringValuesFromDatabase(dbConnection, sqlStmt, params); } catch (SQLException e) { String errorMessage = "Error Occurred while get String values from database : " + sqlStmt; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt); } return values; }
Source:
protected void doWork(IProgressMonitor monitor) throws Exception { Branch branch = BranchManager.getBranch(this.branch); BranchState originalState = branch.getBranchState(); BranchArchivedState originalArchivedState = branch.getArchiveState(); ArtifactCache.deCache(this.branch); try { branch.setBranchState(BranchState.DELETE_IN_PROGRESS); branch.setArchived(true); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.Deleting, branch.getGuid())); BranchManager.persist(branch); branch.setBranchState(BranchState.DELETED); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.Deleted, branch.getGuid())); BranchManager.persist(branch); } catch (Exception ex) { branch.setBranchState(originalState); branch.setArchived(originalArchivedState.isArchived()); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.StateUpdated, branch.getGuid())); BranchManager.persist(branch); throw ex; } }

Target:
protected void doWork(IProgressMonitor monitor) throws Exception { Branch branch = BranchManager.getBranch(this.branch); BranchState originalState = branch.getBranchState(); BranchArchivedState originalArchivedState = branch.getArchiveState(); ArtifactCache.deCache(this.branch); try { branch.setBranchState(BranchState.DELETE_IN_PROGRESS); branch.setArchived(true); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.Deleting, branch.getGuid())); BranchManager.persist(branch); branch.setBranchState(BranchState.DELETED); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.Deleted, branch.getGuid())); BranchManager.persist(branch); } catch (Exception ex) { try { branch.setBranchState(originalState); branch.setArchived(originalArchivedState.isArchived()); OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.StateUpdated, branch.getGuid())); BranchManager.persist(branch); } catch (Exception ex2) { log(ex2); } throw ex; } }
Source:
public void testContinueInitializationOnError() throws Exception { testAcceptorApplication = new TestAcceptorApplication(3); int freePort1 = AvailablePortFinder.getNextAvailable(); int freePort2 = AvailablePortFinder.getNextAvailable(); int freePort3 = AvailablePortFinder.getNextAvailable(); Acceptor acceptor = createAcceptor(freePort1, freePort2, freePort3, true); acceptor.start(); List<SessionID> acceptorSessions = acceptor.getSessions(); assertEquals(2, acceptorSessions.size()); SessionID session1 = new SessionID(FixVersions.BEGINSTRING_FIX42, "ACCEPTOR-" + 1, "INITIATOR"); SessionID session3 = new SessionID(FixVersions.BEGINSTRING_FIX42, "ACCEPTOR-" + 3, "INITIATOR"); assertTrue(acceptorSessions.contains(session1)); assertTrue(acceptorSessions.contains(session3)); acceptor.stop(true); }

Target:
public void testContinueInitializationOnError() throws Exception { testAcceptorApplication = new TestAcceptorApplication(3); int freePort1 = AvailablePortFinder.getNextAvailable(); int freePort2 = AvailablePortFinder.getNextAvailable(); int freePort3 = AvailablePortFinder.getNextAvailable(); Acceptor acceptor = createAcceptor(freePort1, freePort2, freePort3, true); acceptor.start(); List<SessionID> acceptorSessions = acceptor.getSessions(); assertEquals(2, acceptorSessions.size()); SessionID session1 = new SessionID(FixVersions.BEGINSTRING_FIX42, "ACCEPTOR-" + 1, "INITIATOR"); SessionID session2 = new SessionID(FixVersions.BEGINSTRING_FIX42, "ACCEPTOR-" + 2, "INITIATOR"); SessionID session3 = new SessionID(FixVersions.BEGINSTRING_FIX42, "ACCEPTOR-" + 3, "INITIATOR"); assertTrue(acceptorSessions.contains(session1)); assertFalse(acceptorSessions.contains(session2)); assertTrue(acceptorSessions.contains(session3)); acceptor.stop(true); }
Source:
public static void sendPlainText(final String content, final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { final String enc = Constants.CHARACTER_ENCODING; final byte[] raw = content.getBytes(enc); rsp.setContentType("text/plain"); rsp.setCharacterEncoding(enc); send(raw, req, rsp); }

Target:
public static void sendPlainText(final String content, final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { final byte[] raw = content.getBytes(Constants.CHARACTER_ENCODING); rsp.setContentType(TEXT_PLAIN); rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING); send(raw, req, rsp); }