auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void OnFinishSelected() { FragmentManager mgr = getSupportFragmentManager(); final Transaction transaction = new Transaction(); transaction.setUser((User) User.getCurrentUser()); AmountInputFragment amountFragment = (AmountInputFragment) mgr .findFragmentByTag(AmountInputFragment.class.getName()); transaction.setAmount(Double.parseDouble(amountFragment.getAmountSelected())); transaction.setName(getString(R.string.label_goal_payment)); transaction.setGoal(goal); transaction.setTransactionDate(new Date()); transaction.setType(TransactionType.CREDIT); transaction.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { <START> Toast.makeText(AddGoalPaymentActivity.this, "Done savign txn", <END> Toast.LENGTH_LONG).show(); Intent txnData = new Intent(); txnData.putExtra(Transaction.NAME_KEY, transaction); setResult(RESULT_OK, txnData); setResult(RESULT_OK, txnData); finish(); } else { Log.e("goal", e.getLocalizedMessage(), e); Toast.makeText(AddGoalPaymentActivity.this, R.string.parse_error_saving, Toast.LENGTH_SHORT).show(); } } }); }</code><technical_language>Text live [strings.xml](<LINK_0></technical_language>

Target:
public void OnFinishSelected() { FragmentManager mgr = getSupportFragmentManager(); Category txnCategory = ParseObject.createWithoutData(Category.class, "93BaEoZPfo"); final Transaction transaction = new Transaction(); transaction.setUser((User) User.getCurrentUser()); AmountInputFragment amountFragment = (AmountInputFragment) mgr .findFragmentByTag(AmountInputFragment.class.getName()); transaction.setAmount(Double.parseDouble(amountFragment.getAmountSelected())); transaction.setName(getString(R.string.label_goal_payment)); transaction.setGoal(goal); transaction.setTransactionDate(new Date()); transaction.setType(TransactionType.CREDIT); transaction.setCategory(txnCategory); transaction.pinInBackground(ParseUtils.PIN_CALLBACK); Intent txnData = new Intent(); txnData.putExtra(Transaction.NAME_KEY, transaction.getObjectId()); setResult(RESULT_OK, txnData); finish(); }
Source:
<code>void onRequest(Exchange exchange, SpanCustomizer span) { span.name(spanName); span.tag("camel.client.endpoint.url", url); span.tag("camel.client.exchange.id", exchange.getExchangeId()); span.tag("camel.client.exchange.pattern", exchange.getPattern().name()); if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) { boolean streams = eventNotifier.isIncludeMessageBodyStreams(); StreamCache cache = prepareBodyForLogging(exchange, streams); String body = MessageHelper.extractBodyForLogging(exchange.getMessage(), "", streams, streams); span.tag("camel.client.exchange.message.request.body", body); if (cache != null) { cache.reset(); } } <START> Object clientTagsObj = exchange.getProperty("camel.custom.tags"); <END> if (clientTagsObj != null) { Map<String, String> clientTags = (Map)clientTagsObj; if (clientTags != null && !clientTags.isEmpty()) { for (Map.Entry<String, String> tag: clientTags.entrySet()) { span.tag("custom." + tag.getKey(), tag.getValue()); } } } }</code><technical_language>camel.client.customtags camel.client prefix. exchange.getProperty("xxx", Map.class);</technical_language>

Target:
void onRequest(Exchange exchange, SpanCustomizer span) { span.name(spanName); span.tag("camel.client.endpoint.url", url); span.tag("camel.client.exchange.id", exchange.getExchangeId()); span.tag("camel.client.exchange.pattern", exchange.getPattern().name()); if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) { boolean streams = eventNotifier.isIncludeMessageBodyStreams(); StreamCache cache = prepareBodyForLogging(exchange, streams); String body = MessageHelper.extractBodyForLogging(exchange.getMessage(), "", streams, streams); span.tag("camel.client.exchange.message.request.body", body); if (cache != null) { cache.reset(); } } Map<String, String> customTags = exchange.getProperty("camel.client.customtags", Map.class); if (customTags != null && !customTags.isEmpty()) { for (Map.Entry<String, String> tag : customTags.entrySet()) { span.tag("custom." + tag.getKey(), tag.getValue()); } } }
Source:
<code>public void start(Stage primaryStage) throws Exception { <START> ready.addListener(event -> { <END> Platform.runLater(() -> { stage = primaryStage; stage.setTitle(DNAINATOR); stage.getIcons().add(new Image(getClass().getResourceAsStream(ICON))); stage.setMinWidth(MIN_WIDTH); stage.setMinHeight(MIN_HEIGHT); stage.setMaximized(true); notifyPreloader(new Preloader.ProgressNotification(1)); try { BorderPane rootLayout = FXMLLoader.load(getClass().getResource(FXML)); stage.setScene(new Scene(rootLayout)); stage.show(); } catch (IOException e) { e.printStackTrace(); } }); }); }</code><technical_language>if this happen, want load switch of property true</technical_language>

Target:
public void start(Stage primaryStage) throws Exception { ready.addListener(event -> { Platform.runLater(() -> { primaryStage.setTitle(DNAINATOR); primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(ICON))); primaryStage.setMinWidth(MIN_WIDTH); primaryStage.setMinHeight(MIN_HEIGHT); notifyPreloader(new Preloader.ProgressNotification(1)); try { BorderPane rootLayout = FXMLLoader.load(getClass().getResource(FXML)); Scene scene = new Scene(rootLayout, getScreenWidth(), getScreenHeight()); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } }); }); }
Source:
<code>protected void configure() { <START> install(new CacheModule() { <END> @Override protected void configure() { cache(PROJECT_DOC_RESOURCES, ResourceKey.class, Resource.class) .maximumWeight(2 << 20) .weigher(ResourceWeigher.class); } }); }</code><technical_language>is this needed? subclassing a CacheModule. This method body lines 30-32</technical_language>

Target:
protected void configure() { cache(PROJECT_DOC_RESOURCES, ResourceKey.class, Resource.class) .maximumWeight(2 << 20) .weigher(ResourceWeigher.class); }
Source:
<code><START> public void theResponseDeviceIsInactiveShouldBeGiven(final String arg1) throws Throwable { <END> this.notOkRequestRunner(PROPERTIES_MAP, TEST_CASE_NAME_REQUEST, TEST_CASE_XML, TEST_SUITE_XML, LOGGER); assertTrue(this.response.indexOf(arg1) > 0); }</code><technical_language>A parameter name more meaningful arg1 I imagine</technical_language>

Target:
public void theResponseDeviceIsInactiveShouldBeGiven(final String arg1) throws Throwable { assertTrue(this.runXpathResult.assertXpath(this.response, PATH_REQUEST_RESPONSE, arg1)); }
Source:
<code>@VisibleForTesting String getGitDescribe(@NotNull Repository repository) throws MojoExecutionException { try { DescribeResult describeResult = DescribeCommand .on(repository) <START> .withMojo(mojo) <END> .apply(super.gitDescribe) .call(); return describeResult.toString(); } catch (GitAPIException ex) { ex.printStackTrace(); throw new MojoExecutionException("Unable to obtain git.commit.id.describe information", ex); } }</code><technical_language>setVerbose describe is gone</technical_language>

Target:
@VisibleForTesting String getGitDescribe(@NotNull Repository repository) throws GitCommitIdExecutionException { try { DescribeResult describeResult = DescribeCommand .on(repository, log) .apply(super.gitDescribe) .call(); return describeResult.toString(); } catch (GitAPIException ex) { ex.printStackTrace(); throw new GitCommitIdExecutionException("Unable to obtain git.commit.id.describe information", ex); } }
Source:
<code>public void readLac(final BookieSocketAddress addr, final long ledgerId, final ReadLacCallback cb, final Object ctx) { final PerChannelBookieClientPool client = lookupClient(addr); if (client == null) { cb.readLacComplete(getRc(BKException.Code.BookieHandleNotAvailableException), ledgerId, null, null, ctx); return; } client.obtain((rc, pcbc) -> { if (rc != BKException.Code.OK) { try { executor.executeOrdered(ledgerId, safeRun(() -> { cb.readLacComplete(rc, ledgerId, null, null, ctx); })); } catch (RejectedExecutionException re) { cb.readLacComplete(getRc(BKException.Code.InterruptedException), ledgerId, null, null, ctx); } } else { pcbc.readLac(ledgerId, cb, ctx); } <START> }, ledgerId, conf.getUseV2WireProtocol()); <END> }</code><technical_language>I conf.getUseV2WireProtocol(). true /* forceUseV3 *, right</technical_language>

Target:
public void readLac(final BookieSocketAddress addr, final long ledgerId, final ReadLacCallback cb, final Object ctx) { final PerChannelBookieClientPool client = lookupClient(addr); if (client == null) { cb.readLacComplete(getRc(BKException.Code.BookieHandleNotAvailableException), ledgerId, null, null, ctx); return; } client.obtain((rc, pcbc) -> { if (rc != BKException.Code.OK) { try { executor.executeOrdered(ledgerId, safeRun(() -> { cb.readLacComplete(rc, ledgerId, null, null, ctx); })); } catch (RejectedExecutionException re) { cb.readLacComplete(getRc(BKException.Code.InterruptedException), ledgerId, null, null, ctx); } } else { pcbc.readLac(ledgerId, cb, ctx); } }, ledgerId, useV3Enforced); }
Source:
<code>public void setPreferredAgencies(String s) { if (s != null && !s.equals("")) <START> preferredAgencies = Sets.newHashSet(s.split(",")); <END> }</code><technical_language>"This method is useful deprecated in future."</technical_language>

Target:
public void setPreferredAgencies(String s) { if (!s.isEmpty()) { preferredAgencies = new HashSet<>(); Collections.addAll(preferredAgencies, s.split(",")); } }
Source:
<code>public void testUnmarshallSubprocessLevelEventWithEdgesEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateMessageEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_WITH_INCOME_SUBPROCESS_LEVEL_EVENT_ID, HAS_INCOME_EDGE, HAS_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); <START> assertMessageEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, ""); <END> assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); }</code><technical_language>suggestion assertMessageEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, EMPTY_VALUE);</technical_language>

Target:
public void testUnmarshallSubprocessLevelEventWithEdgesEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateMessageEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_WITH_INCOME_SUBPROCESS_LEVEL_EVENT_ID, HAS_INCOME_EDGE, HAS_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertMessageEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, EMPTY_VALUE); assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); }
Source:
<code>public void returnsFileContent() throws Exception { final Storage storage = new MkStorage( this.temp.getRoot().getAbsolutePath() ); final String path = "some_file.txt"; final String content = "some text content"; storage.put(path, IOUtils.toInputStream(content)); MatcherAssert.assertThat( IOUtils.toString( new TkGetFile(storage).route( new RqRegex.Fake( <START> "/api/file/(?<path>[^/]+)", <END> String.format( "/api/file/%s", path ) ) ).act().body() ), Matchers.containsString(content) ); }</code><technical_language>I point of this /api/file/ prefix here. (?<path>.*) here</technical_language>

Target:
public void returnsFileContent() throws Exception { final Storage storage = new MkStorage( this.temp.getRoot().getAbsolutePath() ); final String path = "some_file.txt"; final String content = "some text content"; storage.put(path, IOUtils.toInputStream(content)); MatcherAssert.assertThat( new RsPrint( new TkGetFile(storage).route( new RqRegex.Fake( "/api/file/(?<path>[^/]+)", String.format( "/api/file/%s", path ) ) ).act() ).printBody(), Matchers.containsString(content) ); }
Source:
<code>public boolean isMemberOf(IEntityGroup group) throws GroupsException { final Set<IEntityGroup> parents = getParentGroups(); <START> return parents.contains(group); <END> }</code><technical_language>Refactor 1 line</technical_language>

Target:
public boolean isMemberOf(IEntityGroup group) throws GroupsException { return getParentGroups().contains(group); }
Source:
<code>public GraphModel adapt(Map<String, Object> data) { final Set<Long> nodeIdentities = new HashSet<>(); final Set<Long> edgeIdentities = new HashSet<>(); DefaultGraphModel graphModel = new DefaultGraphModel(); for (Map.Entry<String, Object> mapEntry : data.entrySet()) { final Object value = mapEntry.getValue(); String resultKey = mapEntry.getKey(); <START> boolean generatedNodes = AdapterUtils.matchesPatternComprehension(resultKey); <END> adaptInternal(nodeIdentities, edgeIdentities, graphModel, value, generatedNodes); } return graphModel; }</code><technical_language>I dislike relationship generatedNodes matchesPatternComprehension. get renamed in AdapterUtils show purpose of method technical details</technical_language>

Target:
public GraphModel adapt(Map<String, Object> data) { final Set<Long> nodeIdentities = new HashSet<>(); final Set<Long> edgeIdentities = new HashSet<>(); DefaultGraphModel graphModel = new DefaultGraphModel(); for (Map.Entry<String, Object> mapEntry : data.entrySet()) { final Object value = mapEntry.getValue(); String resultKey = mapEntry.getKey(); boolean generatedNodes = AdapterUtils.describesGeneratedNode(resultKey); adaptInternal(nodeIdentities, edgeIdentities, graphModel, value, generatedNodes); } return graphModel; }
Source:
<code>public Datastream createBootstrapDatastream(String datastreamName) throws DatastreamException { ActionRequest<Datastream> request = _bootstrapBuilders.actionCreate().paramBaseDatastream(datastreamName).build(); ResponseFuture<Datastream> datastreamResponseFuture = _restClient.sendRequest(request); Response<Datastream> response; try { response = datastreamResponseFuture.getResponse(); return response.getEntity(); } catch (RemoteInvocationException e) { if(e instanceof RestLiResponseException && ((RestLiResponseException) e).getStatus() == HttpStatus.S_404_NOT_FOUND.getCode()) { throw new DatastreamNotFoundException(datastreamName, e); } else { throw new DatastreamException(String.format( <START> "Create Bootstrap Datastream {%s} failed with error %s", datastreamName, e.toString()), e); <END> } } }</code><technical_language>above, print outer DatastreamException</technical_language>

Target:
public Datastream createBootstrapDatastream(String datastreamName) throws DatastreamException { ActionRequest<Datastream> request = _bootstrapBuilders.actionCreate().paramBaseDatastream(datastreamName).build(); ResponseFuture<Datastream> datastreamResponseFuture = _restClient.sendRequest(request); Response<Datastream> response; try { response = datastreamResponseFuture.getResponse(); return response.getEntity(); } catch (RemoteInvocationException e) { if(e instanceof RestLiResponseException && ((RestLiResponseException) e).getStatus() == HttpStatus.S_404_NOT_FOUND.getCode()) { throw new DatastreamNotFoundException(datastreamName, e); } else { throw new DatastreamException(String.format( "Create Bootstrap Datastream {%s} failed with error.", datastreamName), e); } } }
Source:
<code>public void persistDeviceBusInfo(UserVmVO vm, String rootDiskController) { <START> String existingVmRootDiskController = vm.getDetail(VmDetailConstants.ROOK_DISK_CONTROLLER); <END> if (StringUtils.isEmpty(existingVmRootDiskController) && !StringUtils.isEmpty(rootDiskController)) { vm.setDetail(VmDetailConstants.ROOK_DISK_CONTROLLER, rootDiskController); _vmDao.saveDetails(vm); s_logger.debug("Persisted device bus information rootDiskController=" + rootDiskController + " for vm: " + vm.getDisplayName()); } }</code><technical_language>fixing typo "ROOK_DISK_CONTROLLER"</technical_language>

Target:
public void persistDeviceBusInfo(UserVmVO vm, String rootDiskController) { String existingVmRootDiskController = vm.getDetail(VmDetailConstants.ROOT_DISK_CONTROLLER); if (StringUtils.isEmpty(existingVmRootDiskController) && !StringUtils.isEmpty(rootDiskController)) { vm.setDetail(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDiskController); _vmDao.saveDetails(vm); if (s_logger.isDebugEnabled()) { s_logger.debug("Persisted device bus information rootDiskController=" + rootDiskController + " for vm: " + vm.getDisplayName()); } } }
Source:
<code>ServerChecker doCreateChecker(URL url, String serverRef) { if ("terminal".equals(serverRef)) { return new TerminalHttpConnectionServerChecker( url, machineName, serverRef, 3, 180, 1, TimeUnit.SECONDS, timer); } if ("wsagent/http".equals(serverRef)) { return new HttpConnectionServerChecker( url, machineName, serverRef, <START> 3, <END> 180, wsagentPingSuccessThreshold, TimeUnit.SECONDS, timer); } return new HttpConnectionServerChecker( url, machineName, serverRef, 3, 180, 1, TimeUnit.SECONDS, timer); }</code><technical_language>@ibuziuk elaborate terminal exec agents need a threshold = 3 wsagent needs it</technical_language>

Target:
ServerChecker doCreateChecker(URL url, String serverRef) { if ("terminal".equals(serverRef)) { return new TerminalHttpConnectionServerChecker( url, machineName, serverRef, 3, 180, serverPingSuccessThreshold, TimeUnit.SECONDS, timer); } return new HttpConnectionServerChecker( url, machineName, serverRef, 3, 180, serverPingSuccessThreshold, TimeUnit.SECONDS, timer); }
Source:
<code>public boolean resetModem() { boolean retVal = true; if (KuraConstants.ReliaGATE_10_05.getTargetName().equals(TARGET_NAME)) { try { if (!isSysfsGpioExported(RELIAGATE_10_05_GSM_RESET_GPIO_NUM)) { initSysfsGpio(RELIAGATE_10_05_GSM_RESET_GPIO_NUM, false); } echoSysfsResource(RELIAGATE_10_05_GSM_USB_PATH, false); Thread.sleep(1000); pulseSysfsGpio(RELIAGATE_10_05_GSM_RESET_GPIO_NUM, true, 1000); Thread.sleep(1000); echoSysfsResource(RELIAGATE_10_05_GSM_USB_PATH, true); <START> int cnt = 10; <END> while (!isOn() && cnt > 0) { sleep(1000); cnt--; } if (!isOn()) { retVal = false; } } catch (IOException e) { s_logger.error("Failed to write to gpio", e); retVal = false; } catch (KuraException e) { s_logger.error("Failed to detect modem", e); retVal = false; } catch (InterruptedException e) { s_logger.error("Interrupted Exception during sleep", e); retVal = false; } } else { s_logger.warn("resetModem() :: modem reset operation is not supported for the platform", TARGET_NAME); } return retVal; }</code><technical_language>I retVal defined false, in line 289 if (isOn) { retVal = true;} This prevent retVal=false in catches</technical_language>

Target:
public boolean resetModem() { boolean retVal = false; if (KuraConstants.ReliaGATE_10_05.getTargetName().equals(TARGET_NAME)) { try { if (!isSysfsGpioExported(RELIAGATE_10_05_GSM_RESET_GPIO_NUM)) { initSysfsGpio(RELIAGATE_10_05_GSM_RESET_GPIO_NUM, false); } echoSysfsResource(RELIAGATE_10_05_GSM_USB_PATH, false); Thread.sleep(1000); pulseSysfsGpio(RELIAGATE_10_05_GSM_RESET_GPIO_NUM, true, 1000); Thread.sleep(1000); echoSysfsResource(RELIAGATE_10_05_GSM_USB_PATH, true); int cnt = 10; while (!isOn() && cnt > 0) { sleep(1000); cnt--; } if (isOn()) { retVal = true; } } catch (IOException e) { s_logger.error("Failed to write to gpio", e); } catch (KuraException e) { s_logger.error("Failed to detect modem", e); } catch (InterruptedException e) { s_logger.error("Interrupted Exception during sleep", e); } } else { s_logger.warn("resetModem() :: modem reset operation is not supported for the platform", TARGET_NAME); } return retVal; }
Source:
<code>protected void loadContributions() { if (Platform.isRunning()) { delegatesParticipants.clear(); <START> IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.sirius.migrationParticipant"); <END> for (IConfigurationElement configurationElement : config) { try { String kind = configurationElement.getAttribute("kind"); if (kind.equals(getKind())) { Object contribution = configurationElement.createExecutableExtension("class"); if (contribution instanceof IMigrationParticipant) { delegatesParticipants.add((IMigrationParticipant) contribution); } } } catch (CoreException e) { SiriusPlugin.getDefault().getLog().log(new Status(Status.WARNING, SiriusPlugin.ID, "Cannot instanciate migration contribution", e)); } } } }</code><technical_language>again, instead of scattering code if() statements, more robust a wrapper method replacing calls "Platform.getExtensionRegistry().getConfigurationElementsFor" check return empty table if platform is running</technical_language>

Target:
protected void loadContributions() { delegatesParticipants.clear(); IConfigurationElement[] config = EclipseUtil.getConfigurationElementsFor("org.eclipse.sirius.migrationParticipant"); for (IConfigurationElement configurationElement : config) { try { String kind = configurationElement.getAttribute("kind"); if (kind.equals(getKind())) { Object contribution = configurationElement.createExecutableExtension("class"); if (contribution instanceof IMigrationParticipant) { delegatesParticipants.add((IMigrationParticipant) contribution); } } } catch (CoreException e) { SiriusPlugin.getDefault().getLog().log(new Status(Status.WARNING, SiriusPlugin.ID, "Cannot instanciate migration contribution", e)); } } }
Source:
<code>public void testMulticastSocket(MulticastSocket receiveSocket, InetAddress sendAddress, boolean expectSuccessfulRead) throws IOException { MulticastSocket sendSocket = new MulticastSocketFactoryImpl().createMulticastSocket(sendAddress, PORT); try { sendSocket.joinGroup(sendAddress); String data = "1234567890"; byte[] buffer = data.getBytes(); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, sendAddress, PORT); if (ADVERTISE_INTERFACE != null && !System.getProperty("os.name").startsWith("Windows")) { try { InetAddress socketInterface = InetAddress.getByName(ADVERTISE_INTERFACE); sendSocket.setInterface(socketInterface); } catch (Exception ex) { ; } } sendSocket.send(packet); try { Thread.sleep(20); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } Arrays.fill(buffer, (byte) 0); packet = new DatagramPacket(buffer, buffer.length); try { receiveSocket.receive(packet); <START> System.out.println("MERDE: " + expectSuccessfulRead + " : " + buffer + " : " + data); <END> System.out.println("MERDE: " + expectSuccessfulRead + " : " + buffer + " : " + data.getBytes()); Assert.assertTrue(expectSuccessfulRead); Assert.assertArrayEquals(buffer, data.getBytes()); } catch (SocketTimeoutException e) { Assert.assertFalse(expectSuccessfulRead); } try { sendSocket.leaveGroup(sendAddress); } catch (java.net.SocketException ex) { } } finally { sendSocket.close(); } }</code><technical_language>LOL, lets nice, no? :)</technical_language>

Target:
public void testMulticastSocket(MulticastSocket receiveSocket, InetAddress sendAddress, boolean expectSuccessfulRead) throws IOException { MulticastSocket sendSocket = new MulticastSocketFactoryImpl().createMulticastSocket(sendAddress, PORT); try { sendSocket.joinGroup(sendAddress); String data = "1234567890"; byte[] buffer = data.getBytes(); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, sendAddress, PORT); if (ADVERTISE_INTERFACE != null && !System.getProperty("os.name").startsWith("Windows")) { try { InetAddress socketInterface = InetAddress.getByName(ADVERTISE_INTERFACE); sendSocket.setInterface(socketInterface); } catch (Exception ex) { ; } } sendSocket.send(packet); try { Thread.sleep(20); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } Arrays.fill(buffer, (byte) 0); packet = new DatagramPacket(buffer, buffer.length); try { receiveSocket.receive(packet); Assert.assertTrue(expectSuccessfulRead); Assert.assertArrayEquals(buffer, data.getBytes()); } catch (SocketTimeoutException e) { Assert.assertFalse(expectSuccessfulRead); } try { sendSocket.leaveGroup(sendAddress); } catch (java.net.SocketException ex) { } } finally { sendSocket.close(); } }
Source:
<code>public abstract void killRecursively() throws InterruptedException; protected @CheckForNull VetoCause getVeto() { String causeMessage = null; try { <START> VirtualChannel channelToMaster = SlaveComputer.getChannelToMaster(); <END> if (channelToMaster!=null) { CheckVetoes vetoCheck = new CheckVetoes(this); causeMessage = channelToMaster.call(vetoCheck); } } catch (IOException e) { LOGGER.log(Level.WARNING, "I/O Exception while checking for vetoes", e); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, "Interrupted Exception while checking for vetoes", e); } if (causeMessage != null) { return new VetoCause(causeMessage); } return null; }</code><technical_language>IIUC work properly master, result null</technical_language>

Target:
public abstract void killRecursively() throws InterruptedException; protected @CheckForNull VetoCause getVeto() { String causeMessage = null; if (!skipVetoes) { try { VirtualChannel channelToMaster = SlaveComputer.getChannelToMaster(); if (channelToMaster!=null) { CheckVetoes vetoCheck = new CheckVetoes(this); causeMessage = channelToMaster.call(vetoCheck); } } catch (IOException e) { LOGGER.log(Level.WARNING, "I/O Exception while checking for vetoes", e); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, "Interrupted Exception while checking for vetoes", e); } } if (causeMessage != null) { return new VetoCause(causeMessage); } return null; }
Source:
<code>public void sign_sameAs() throws IOException { MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory(); final String accessToken = "1/MkSJoj1xsli0AccessToken_NKPY2"; String defaultAccountEmail = "mail@mail.com"; byte[] expectedSignature = {0xD, 0xE, 0xA, 0xD}; transportFactory.transport.setAccessToken(accessToken); transportFactory.transport.setServiceAccountEmail(defaultAccountEmail); transportFactory.transport.setSignature(expectedSignature); ComputeEngineCredentials credentials = ComputeEngineCredentials.newBuilder().setHttpTransportFactory(transportFactory).build(); <START> assertEquals(defaultAccountEmail, credentials.getAccount()); <END> }</code><technical_language>I want test signature in this test. assertions split getAccount() test test</technical_language>

Target:
public void sign_sameAs() throws IOException { MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory(); final String accessToken = "1/MkSJoj1xsli0AccessToken_NKPY2"; String defaultAccountEmail = "mail@mail.com"; byte[] expectedSignature = {0xD, 0xE, 0xA, 0xD}; transportFactory.transport.setAccessToken(accessToken); transportFactory.transport.setServiceAccountEmail(defaultAccountEmail); transportFactory.transport.setSignature(expectedSignature); ComputeEngineCredentials credentials = ComputeEngineCredentials.newBuilder().setHttpTransportFactory(transportFactory).build(); assertArrayEquals(expectedSignature, credentials.sign(expectedSignature)); }
Source:
<code><START> public void setName(EntityModel<String> name) { <END> this.name = name; }</code><technical_language>I reason for setters public</technical_language>

Target:
private void setName(EntityModel<String> name) { this.name = name; }
Source:
<code>public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Flow other = (Flow) obj; <START> return new EqualsBuilder() <END> .append(elements, other.elements) .append(exceptional, other.exceptional) .isEquals(); }</code><technical_language>I Objects.equals JDK, reduce external dependencies</technical_language>

Target:
public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Flow other = (Flow) obj; return Objects.equal(elements, other.elements) && exceptional == other.exceptional; }
Source:
<code>protected void executeCommand() { Guid secretUuid = getParameters().getLibvirtSecret().getId(); <START> addCustomValue("LibvirtSecretUUID", secretUuid.toString()); <END> getReturnValue().setActionReturnValue(secretUuid); }</code><technical_language>add method : public String getLibvirtSeverUUID() for audit log purposes</technical_language>

Target:
protected void executeCommand() { getReturnValue().setActionReturnValue(getParameters().getLibvirtSecret().getId()); }
Source:
<code>public Builder setPathPart(String path) { switch (type) { case PATH: case DIFF: this.path = maybeTrimLeadingAndTrailingSlash(checkNotNull(path)); break; case DESCRIBE: case REFS: case LOG: this.path = path != null ? maybeTrimLeadingAndTrailingSlash(path) : null; break; default: checkState(path == null, "cannot set path on %s view", type); this.path = path; break; } <START> return this; <END> }</code><technical_language>nit: here. Leave checks in switch do assignment end: this.path = path != null ? maybeTrimLeadingAndTrailingSlash(path) : null;</technical_language>

Target:
public Builder setPathPart(String path) { switch (type) { case PATH: case DIFF: this.path = maybeTrimLeadingAndTrailingSlash(checkNotNull(path)); return this; case DESCRIBE: case REFS: case LOG: this.path = path != null ? maybeTrimLeadingAndTrailingSlash(path) : null; return this; default: throw new IllegalStateException(String.format("cannot set path on %s view", type)); } }
Source:
<code>@Override public Iterable<K> loadAllKeys() { logger.info( "Starting load all keys for map {}", mapName ); <START> return new PostgresIterable<>( <END> () -> { try { Connection connection = hds.getConnection(); connection.setAutoCommit( false ); Statement stmt = connection.createStatement(); stmt.setFetchSize( 50_000 ); ResultSet rs = stmt.executeQuery( selectAllKeysQuery ); return new StatementHolder( connection, stmt, rs ); } catch ( SQLException e ) { logger.error( "Unable to load all keys", e ); throw new IllegalStateException( "Unable to load all keys.", e ); } }, rs -> { try { return mapToKey( rs ); } catch ( SQLException e ) { logger.error( "Unable to read keys for map {}.", mapName, e); throw new IllegalStateException( "Unable to read keys.", e ); } } ); }</code><technical_language>BasePostgresIterable instead</technical_language>

Target:
@Override public Iterable<K> loadAllKeys() { logger.info( "Starting load all keys for map {}", mapName ); return new BasePostgresIterable<>( new StatementHolderSupplier( hds, selectAllKeysQuery, 50_000, false, 0L), rs -> { try { return mapToKey( rs ); } catch ( SQLException e ) { logger.error( "Unable to read keys for map {}.", mapName, e); throw new IllegalStateException( "Unable to read keys.", e ); } } ); }
Source:
<code>public void testTransferCodingGZIP() { String requestStr = "POST / HTTP/1.1\r\n" + "Content-Length: " + GZ_HELLO_WORLD.length + "\r\n" + "Transfer-Encoding: gzip\r\n" + "\r\n"; HttpRequestDecoder decoder = new HttpRequestDecoder(); HttpContentDecoder decompressor = new HttpContentDecompressor(); EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor); channel.writeInbound(Unpooled.copiedBuffer(requestStr.getBytes())); channel.writeInbound(Unpooled.copiedBuffer(GZ_HELLO_WORLD)); HttpRequest request = channel.readInbound(); assertTrue(request.decoderResult().isSuccess()); <START> assertFalse(request.headers().contains("Content-Length")); <END> HttpContent content = channel.readInbound(); assertTrue(content.decoderResult().isSuccess()); assertEquals(HELLO_WORLD, content.content().toString(CharsetUtil.US_ASCII)); content.release(); LastHttpContent lastHttpContent = channel.readInbound(); assertTrue(lastHttpContent.decoderResult().isSuccess()); lastHttpContent.release(); assertHasInboundMessages(channel, false); assertHasOutboundMessages(channel, false); assertFalse(channel.finish()); channel.releaseInbound(); }</code><technical_language>Consider HttpHeaderNames.CONTENT_LENGTH constant</technical_language>

Target:
public void testTransferCodingGZIP() { String requestStr = "POST / HTTP/1.1\r\n" + "Content-Length: " + GZ_HELLO_WORLD.length + "\r\n" + "Transfer-Encoding: gzip\r\n" + "\r\n"; HttpRequestDecoder decoder = new HttpRequestDecoder(); HttpContentDecoder decompressor = new HttpContentDecompressor(); EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor); channel.writeInbound(Unpooled.copiedBuffer(requestStr.getBytes())); channel.writeInbound(Unpooled.copiedBuffer(GZ_HELLO_WORLD)); HttpRequest request = channel.readInbound(); assertTrue(request.decoderResult().isSuccess()); assertFalse(request.headers().contains(HttpHeaderNames.CONTENT_LENGTH)); HttpContent content = channel.readInbound(); assertTrue(content.decoderResult().isSuccess()); assertEquals(HELLO_WORLD, content.content().toString(CharsetUtil.US_ASCII)); content.release(); LastHttpContent lastHttpContent = channel.readInbound(); assertTrue(lastHttpContent.decoderResult().isSuccess()); lastHttpContent.release(); assertHasInboundMessages(channel, false); assertHasOutboundMessages(channel, false); assertFalse(channel.finish()); channel.releaseInbound(); }
Source:
<code>public void catchingExceptionDuringAnnotation() { EntryImpl change = new EntryImpl(); change.setParent(ChangeLogSet.createEmpty(null)); boolean notCaught = false; try { change.getMsgAnnotated(); } catch (Throwable t) { notCaught = true; } assertEquals((new EntryImpl()).getMsg(), change.getMsg()); <START> assertFalse(notCaught); <END> }</code><technical_language>kill notCaught variable fail(t.getMessage()) in catch block instead</technical_language>

Target:
public void catchingExceptionDuringAnnotation() { EntryImpl change = new EntryImpl(); change.setParent(ChangeLogSet.createEmpty(null)); try { change.getMsgAnnotated(); } catch (Throwable t) { fail(t.getMessage()); } assertEquals((new EntryImpl()).getMsg(), change.getMsg()); }
Source:
<code>public String getProvisionedEntityNameByLocalId(String localId) throws IdentityApplicationManagementException { Connection dbConnection = null; String sqlStmt = null; PreparedStatement prepStmt = null; ResultSet rs = null; try { dbConnection = JDBCPersistenceManager.getInstance().getDBConnection(); sqlStmt = IdentityProvisioningConstants.SQLQueries.GET_PROVISIONED_ENTITY_NAME_SQL; prepStmt = dbConnection.prepareStatement(sqlStmt); prepStmt.setString(1, localId); rs = prepStmt.executeQuery(); if (rs.next()) { return rs.getString(1); } else { throw new IdentityApplicationManagementException("Given Local ID does not exist"); } } catch (SQLException | IdentityException e) { IdentityApplicationManagementUtil.rollBack(dbConnection); throw new IdentityApplicationManagementException( "Error occurred while loading Provisioned Entity Name from DB", e); } finally { <START> IdentityApplicationManagementUtil.closeResultSet(rs); <END> IdentityApplicationManagementUtil.closeStatement(prepStmt); IdentityApplicationManagementUtil.closeConnection(dbConnection); } }</code><technical_language>is a singe method close in (DataBaseUitl)</technical_language>

Target:
public String getProvisionedEntityNameByLocalId(String localId) throws IdentityApplicationManagementException { Connection dbConnection = null; String sqlStmt = null; PreparedStatement prepStmt = null; ResultSet rs = null; try { dbConnection = JDBCPersistenceManager.getInstance().getDBConnection(); sqlStmt = IdentityProvisioningConstants.SQLQueries.GET_PROVISIONED_ENTITY_NAME_SQL; prepStmt = dbConnection.prepareStatement(sqlStmt); prepStmt.setString(1, localId); rs = prepStmt.executeQuery(); if (rs.next()) { return rs.getString(1); } else { throw new IdentityApplicationManagementException("Given Local ID :"+localId+" does not exist"); } } catch (SQLException e) { IdentityApplicationManagementUtil.rollBack(dbConnection); throw new IdentityApplicationManagementException( "Error occurred while loading Provisioned Entity Name from DB", e); } finally { IdentityDatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt); } }
Source:
<code>private void showAbortedByHook(final AbortedByHookException cause) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { private String createTitle() { StringBuilder b = new StringBuilder(); b.append(UIText.CommitJob_AbortedByHook); b.append(" \""); b.append(cause.getHookName()); b.append("\""); return b.toString(); <START> } <END> @Override public void run() { MessageDialog.openWarning(PlatformUI.getWorkbench() .getDisplay().getActiveShell(), createTitle(), cause.getHookStdErr()); } }); }</code><technical_language>Give message a {0} MessageFormat</technical_language>

Target:
private void showAbortedByHook(final AbortedByHookException cause) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { private String createTitle() { return MessageFormat.format(UIText.CommitJob_AbortedByHook, cause.getHookName()); } @Override public void run() { MessageDialog.openWarning(PlatformUI.getWorkbench() .getDisplay().getActiveShell(), createTitle(), cause.getHookStdErr()); } }); }
Source:
<code>protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getParameters().getClusterId() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID); return false; } if (Guid.isNullOrEmpty(getParameters().getHookId())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_ID_IS_REQUIRED); return false; <START> } <END> List <VDS> servers = getAllUpServers(getParameters().getClusterId()); if (servers == null || servers.size() == 0) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND); return false; } return true; }</code><technical_language>try fetch hook id, add return failure if found</technical_language>

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getParameters().getClusterId() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID); return false; } if (Guid.isNullOrEmpty(getParameters().getHookId())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_ID_IS_REQUIRED); return false; } if (getGlusterHooksDao().getById(getParameters().getHookId()) == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_DOES_NOT_EXIST); return false; } List <VDS> servers = getAllUpServers(getParameters().getClusterId()); if (servers == null || servers.isEmpty()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_UP_SERVER_FOUND); return false; } return true; }
Source:
<code>private boolean hasAlternativeInstructor(String courseId, String instructorToDeleteEmail) { List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId); boolean isAlternativeInstructorWithModifyInstructorPermissionPresent = false; boolean isAlternativeVisibleInstructorPresent = false; <START> <END> for (InstructorAttributes instr : instructors) { isAlternativeInstructorWithModifyInstructorPermissionPresent = instr.isRegistered() && !instr.getEmail().equals(instructorToDeleteEmail) && instr.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR); if (isAlternativeInstructorWithModifyInstructorPermissionPresent) { break; } } for (InstructorAttributes instr : instructors) { isAlternativeVisibleInstructorPresent = instr.isDisplayedToStudents() && !instr.getEmail().equals(instructorToDeleteEmail); if (isAlternativeVisibleInstructorPresent) { break; } } return isAlternativeInstructorWithModifyInstructorPermissionPresent && isAlternativeVisibleInstructorPresent; }</code><technical_language>replace clunky for loops this: //filter current instructor instructors = instructors.stream().filter((instr) -> !instr.getEmail().equals(instructorToDeleteEmail)).collect (Collectors.toList()); //check for instructor modify permission isAlternativeInstructorWithModifyInstructorPermissionPresent = instructors.stream().anyMatch(instr -> instr .isRegistered() && instr.isAllowedForPrivilege (Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR)); //check for instructor visibility isAlternativeVisibleInstructorPresent = instructors.stream().anyMatch (InstructorAttributes::isDisplayedToStudents);</technical_language>

Target:
private boolean hasAlternativeInstructor(String courseId, String instructorToDeleteEmail) { List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId); boolean hasAlternativeModifyInstructor = false; boolean hasAlternativeVisibleInstructor = false; for (InstructorAttributes instr : instructors) { hasAlternativeModifyInstructor = hasAlternativeModifyInstructor || (instr.isRegistered() && !instr.getEmail().equals(instructorToDeleteEmail) && instr.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR)); hasAlternativeVisibleInstructor = hasAlternativeVisibleInstructor || (instr.isDisplayedToStudents() && !instr.getEmail().equals(instructorToDeleteEmail)); if (hasAlternativeModifyInstructor && hasAlternativeVisibleInstructor) { return true; } } return false; }
Source:
<code>static UsbDevice callUsbDeviceConstructor(@NonNull String name, int vendorId, int productId, int usbClass, int subClass, int protocol, @NonNull Parcelable[] interfaces) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Class<UsbDevice> clazz = (Class<UsbDevice>) Class.forName("android.hardware.usb.UsbDevice"); Constructor<UsbDevice> constructor = clazz.getConstructor(String.class, int.class, int.class, int.class, int.class, int.class, Parcelable[].class); <START> return constructor.newInstance(name, vendorId, productId, usbClass, subClass, protocol); <END> }</code><technical_language>interfaces omitted in calling constructor, causing test fail API 19 (not exception though)</technical_language>

Target:
static UsbDevice callUsbDeviceConstructor(@NonNull String name, int vendorId, int productId, int usbClass, int subClass, int protocol, @NonNull Parcelable[] interfaces) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Class<UsbDevice> clazz = (Class<UsbDevice>) Class.forName("android.hardware.usb.UsbDevice"); Constructor<UsbDevice> constructor = clazz.getConstructor(String.class, int.class, int.class, int.class, int.class, int.class, Parcelable[].class); return constructor.newInstance(name, vendorId, productId, usbClass, subClass, protocol, interfaces); }
Source:
<code>public String getCronExpression(GlusterVolumeSnapshotSchedule schedule) { String retStr = ""; switch (schedule.getRecurrence()) { case INTERVAL: int interval = schedule.getInterval(); <START> retStr = "0 */" + interval + " * * * ? *"; <END> break; case HOURLY: retStr = "0 0 * * * ? *"; break; case DAILY: Time execTime = schedule.getExecutionTime(); retStr = "0 " + execTime.getMinutes() + " " + execTime.getHours() + " * * ? *"; break; case WEEKLY: String days = schedule.getDays(); Time execTime1 = schedule.getExecutionTime(); retStr = "0 " + execTime1.getMinutes() + " " + execTime1.getHours() + " ? * " + days + " *"; break; case MONTHLY: String days1 = schedule.getDays(); Time execTime2 = schedule.getExecutionTime(); retStr = "0 " + execTime2.getMinutes() + " " + execTime2.getHours() + " " + days1 + " * ? *"; break; case UNKNOWN: return null; } return retStr; }</code><technical_language>String.format</technical_language>

Target:
public String getCronExpression(GlusterVolumeSnapshotSchedule schedule) { String retStr = ""; switch (schedule.getRecurrence()) { case INTERVAL: int interval = schedule.getInterval(); retStr = "0 */" + interval + " * * * ? *"; break; case HOURLY: retStr = "0 0 0/1 1/1 * ? *"; break; case DAILY: Time execTime = schedule.getExecutionTime(); retStr = "0 " + execTime.getMinutes() + " " + execTime.getHours() + " * * ? *"; break; case WEEKLY: String days = schedule.getDays(); Time execTime1 = schedule.getExecutionTime(); retStr = "0 " + execTime1.getMinutes() + " " + execTime1.getHours() + " ? * " + days + " *"; break; case MONTHLY: String days1 = schedule.getDays(); Time execTime2 = schedule.getExecutionTime(); retStr = "0 " + execTime2.getMinutes() + " " + execTime2.getHours() + " " + days1 + " * ? *"; break; case UNKNOWN: return null; } return retStr; }
Source:
<code>public boolean imageExists(String image) { if (dockerConnection == null || StringUtils.isBlank(image)) { return false; } DockerImageURI imageName = new DockerImageURI(image); String repo = imageName.getUriWithoutTag(); <START> String tag = imageName.getTag() == null?"latest":imageName.getTag(); <END> return dockerConnection.hasImage(repo, tag); }</code><technical_language>I null <LINK_0> alternate more expressive is StringUtils.defaultIfEmpty(imageName.getTag(), "latest") be#defaultIfBlank(), I remember one</technical_language>

Target:
public boolean imageExists(String image) { if (dockerConnection == null || StringUtils.isBlank(image)) { return false; } DockerImageURI imageName = new DockerImageURI(image); String repo = imageName.getUriWithoutTag(); String tag = StringUtils.defaultIfBlank(imageName.getTag(),"latest"); return dockerConnection.hasImage(repo, tag); }
Source:
<code>public synchronized void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!recogniser.isAvailable()) { LOG.warn("{} is not available for service", recogniser.getClass()); return; } <START> metadata.set("object.rec.impl", recogniser.getClass().getSimpleName()); <END> long start = System.currentTimeMillis(); List<RecognisedObject> objects = recogniser.recognise(stream, handler, metadata, context); LOG.debug("Found objects", objects != null ? objects.size() : 0); LOG.debug("Time taken {}ms", System.currentTimeMillis() - start); if (objects != null && !objects.isEmpty()){ XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startElement("ol", "id", "objects"); Collections.sort(objects, DESC_CONFIDENCE_SORTER); int count = 0; for (RecognisedObject object : objects) { if (object.getConfidence() >= minConfidence) { LOG.debug("Add {}", object); count++; metadata.add(MD_KEY, object.getLabel()); xhtml.startElement("li", "id", object.getId()); String text = String.format(Locale.ENGLISH, " %s [%s](confidence = %f )", object.getLabel(), object.getLabelLang(), object.getConfidence()); xhtml.characters(text); xhtml.endElement("li"); if (count >= topN) { break; } } } xhtml.endElement("ol"); } else { LOG.warn("NO objects"); metadata.add("no.objects", Boolean.TRUE.toString()); } }</code><technical_language>org.apache.tika.parser.recognition.object.rec.impl - IOW prefix o.a.t.p.r</technical_language>

Target:
public synchronized void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!recogniser.isAvailable()) { LOG.warn("{} is not available for service", recogniser.getClass()); return; } metadata.set(MD_REC_IMPL_KEY, recogniser.getClass().getName()); long start = System.currentTimeMillis(); List<RecognisedObject> objects = recogniser.recognise(stream, handler, metadata, context); LOG.debug("Found objects", objects != null ? objects.size() : 0); LOG.debug("Time taken {}ms", System.currentTimeMillis() - start); if (objects != null && !objects.isEmpty()) { XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startElement("ol", "id", "objects"); Collections.sort(objects, DESC_CONFIDENCE_SORTER); int count = 0; for (RecognisedObject object : objects) { if (object.getConfidence() >= minConfidence) { LOG.debug("Add {}", object); count++; String mdValue = String.format(Locale.ENGLISH, "%s (%.5f)", object.getLabel(), object.getConfidence()); metadata.add(MD_KEY, mdValue); xhtml.startElement("li", "id", object.getId()); String text = String.format(Locale.ENGLISH, " %s [%s](confidence = %f )", object.getLabel(), object.getLabelLang(), object.getConfidence()); xhtml.characters(text); xhtml.endElement("li"); if (count >= topN) { break; } } } xhtml.endElement("ol"); } else { LOG.warn("NO objects"); metadata.add("no.objects", Boolean.TRUE.toString()); } }