auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mMapContainer = (FrameLayout) inflater.inflate(R.layout.map_fragment_layout, null); if (mPortalItemId != null) { loadWebMapIntoMapView(mPortalItemId, mBasemapPortalItemId, AccountManager.getInstance().getPortal()); } else { if (mBasemapPortalItemId != null) { loadWebMapIntoMapView(mBasemapPortalItemId, null, AccountManager.getInstance().getAGOLPortal()); } else { String defaultBaseMapURL = getString(R.string.default_basemap_url); mBasemap = new Basemap(defaultBaseMapURL); mMap = new ArcGISMap(mBasemap); <START> MapFragment.mMapView = mMapContainer.findViewById(R.id.map); <END> MapFragment.mMapView.setMap(mMap); setMapView(MapFragment.mMapView); setClickListenerForFloatingActionButton(MapFragment.mMapView); addGraphicLayers(); mMapView.addViewpointChangedListener(new ViewpointChangedListener() { @Override public void viewpointChanged(ViewpointChangedEvent visibleAreaChangedEvent) { mCompass.setRotationAngle(((MapView)visibleAreaChangedEvent.getSource()).getMapRotation()); } }); } } return mMapContainer; }</code><technical_language>I mMapView needs static, this a leak too</technical_language>

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mMapContainer = (FrameLayout) inflater.inflate(R.layout.map_fragment_layout, null); if (mPortalItemId != null) { loadWebMapIntoMapView(mPortalItemId, mBasemapPortalItemId, AccountManager.getInstance().getPortal()); } else { if (mBasemapPortalItemId != null) { loadWebMapIntoMapView(mBasemapPortalItemId, null, AccountManager.getInstance().getAGOLPortal()); } else { String defaultBaseMapURL = getString(R.string.default_basemap_url); mBasemap = new Basemap(defaultBaseMapURL); mMap = new ArcGISMap(mBasemap); mMapView = mMapContainer.findViewById(R.id.map); mMapView.setMap(mMap); setMapView(mMapView); setClickListenerForFloatingActionButton(mMapView); addGraphicLayers(); mMapView.addViewpointChangedListener(new ViewpointChangedListener() { @Override public void viewpointChanged(ViewpointChangedEvent visibleAreaChangedEvent) { mCompass.setRotationAngle(((MapView) visibleAreaChangedEvent.getSource()).getMapRotation()); } }); } } return mMapContainer; }
Source:
<code>public abstract T performTask() throws Throwable; @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void execute() { if (ApiUtil.hasHoneyComb()) { underlyingTask.executeOnExecutor(executor); } else { <START> underlyingTask.execute(); <END> } }</code><technical_language>I vote wait this is affecting Checkstyle task I prefer dabble in Android threading platform differences. leave @BearND final call</technical_language>

Target:
public abstract T performTask() throws Throwable; public void execute() { underlyingTask.executeOnExecutor(executor); }
Source:
<code>public static String getExtension(String mimetype) { String ext = null; if (mimetype.equalsIgnoreCase("audio/mpeg")) { ext = ".mp3"; } else if (mimetype.equalsIgnoreCase("audio/vnd.dlna.adts")) { ext = ".m4a"; } else if (mimetype.equalsIgnoreCase("audio/wav") ) { ext = ".wav"; } else if (mimetype.equalsIgnoreCase("audio/l16")) { ext = ".l16"; <START> <END> } else if (mimetype.equalsIgnoreCase("video/mpeg") || mimetype.equalsIgnoreCase("video/mp4")) { ext = ".mp4"; } if (ext != null) return ext; List<String> list = null; try { list = MimeTypes.getDefaultMimeTypes().forName(mimetype).getExtensions(); Iterator<String> iterator = list.iterator(); while (iterator.hasNext()) { String extension = (String) iterator.next(); if (extension.length() == 4) { ext = extension; break; } } } catch (MimeTypeException e) { LOGGER.warn("Unknown mime type: {}", mimetype); } return ext; }</code><technical_language>@atamariya this commit lines after: L16 other extension exist ".sw" is fy FFmpeg FFmpeg developper Carl Eugen recommended, i is supported renderers ? line 355 need "audio/L16"</technical_language>

Target:
public static String getExtension(String mimetype) { String ext = null; if (mimetype.equalsIgnoreCase("audio/mpeg")) { ext = ".mp3"; } else if (mimetype.equalsIgnoreCase("audio/mp4") || mimetype.equalsIgnoreCase("audio/x-mp4") || mimetype.equalsIgnoreCase("audio/x-m4a")) { ext = ".m4a"; } else if (mimetype.equalsIgnoreCase("audio/x-ogg") || mimetype.equalsIgnoreCase("audio/ogg")) { ext = ".ogg"; } else if (mimetype.equalsIgnoreCase("audio/x-flac") || mimetype.equalsIgnoreCase("audio/flac")) { ext = ".flac"; } else if (mimetype.equalsIgnoreCase("audio/wav") ) { ext = ".wav"; } else if (mimetype.equalsIgnoreCase("audio/l16")) { ext = ".l16"; } else if (mimetype.equalsIgnoreCase("video/mpeg") || mimetype.equalsIgnoreCase("video/mp4")) { ext = ".mp4"; } else if (mimetype.equalsIgnoreCase("video/x-matroska") || mimetype.equalsIgnoreCase("video/x-mkv") || mimetype.equalsIgnoreCase("video/mkv")) { ext = ".mkv"; } else if (mimetype.equalsIgnoreCase("image/webp")) { ext = ".webp"; } if (ext != null) return ext; List<String> list = null; try { list = MimeTypes.getDefaultMimeTypes().forName(mimetype).getExtensions(); Iterator<String> iterator = list.iterator(); while (iterator.hasNext()) { String extension = (String) iterator.next(); if (extension.length() == 4) { ext = extension; break; } } } catch (MimeTypeException e) { LOGGER.warn("Unknown mime type: {}", mimetype); } return ext; }
Source:
<code>public void testOperators() { assertEquals( valueOf(15), valueOf(3).multiply(valueOf(5)) ); assertTrue ( SATOSHI.isPositive() ); assertFalse( SATOSHI.isNegative() ); assertFalse( SATOSHI.isZero() ); assertFalse( NEGATIVE_ONE.isPositive() ); assertTrue ( NEGATIVE_ONE.isNegative() ); assertFalse( NEGATIVE_ONE.isZero() ); assertFalse( ZERO.isPositive() ); assertFalse( ZERO.isNegative() ); assertTrue ( ZERO.isZero() ); assertFalse( Transaction.MIN_NONDUST_OUTPUT.isDust() ); assertTrue ( valueOf(Transaction.MIN_NONDUST_OUTPUT.value - 1).isDust() ); <START> assertTrue ( valueOf(2).isGreaterThan(valueOf(1)) ); <END> assertFalse ( valueOf(2).isGreaterThan(valueOf(2)) ); assertFalse ( valueOf(1).isGreaterThan(valueOf(2)) ); assertTrue ( valueOf(1).isLessThan(valueOf(2)) ); assertFalse ( valueOf(2).isLessThan(valueOf(2)) ); assertFalse ( valueOf(2).isLessThan(valueOf(1)) ); }</code><technical_language>format this? space '(' ')'. space method invocations name '('</technical_language>

Target:
public void testOperators() { assertTrue(SATOSHI.isPositive()); assertFalse(SATOSHI.isNegative()); assertFalse(SATOSHI.isZero()); assertFalse(NEGATIVE_SATOSHI.isPositive()); assertTrue(NEGATIVE_SATOSHI.isNegative()); assertFalse(NEGATIVE_SATOSHI.isZero()); assertFalse(ZERO.isPositive()); assertFalse(ZERO.isNegative()); assertTrue(ZERO.isZero()); assertTrue(valueOf(2).isGreaterThan(valueOf(1))); assertFalse(valueOf(2).isGreaterThan(valueOf(2))); assertFalse(valueOf(1).isGreaterThan(valueOf(2))); assertTrue(valueOf(1).isLessThan(valueOf(2))); assertFalse(valueOf(2).isLessThan(valueOf(2))); assertFalse(valueOf(2).isLessThan(valueOf(1))); }
Source:
<code>public void test() throws Exception { Configuration conf = new Configuration(false); LocalMode lma = LocalMode.newInstance(); DAG dag = lma.getDAG(); super.populateDAG(dag, conf); StreamingApplication app = new StreamingApplication() { @Override public void populateDAG(DAG dag, Configuration conf) { } }; lma.prepareDAG(app, conf); final LocalMode.Controller lc = lma.getController(); lc.run(60000); lc.shutdown(); if (SpillableTestOperator.errorTrace != null) { <START> SpillableTestOperator.errorTrace.printStackTrace(); <END> Assert.assertNull(SpillableTestOperator.errorTrace.getMessage(), SpillableTestOperator.errorTrace); } }</code><technical_language>print stack trace a logger</technical_language>

Target:
public void test() throws Exception { Configuration conf = new Configuration(false); LocalMode lma = LocalMode.newInstance(); DAG dag = lma.getDAG(); super.populateDAG(dag, conf); StreamingApplication app = new StreamingApplication() { @Override public void populateDAG(DAG dag, Configuration conf) { } }; lma.prepareDAG(app, conf); final LocalMode.Controller lc = lma.getController(); lc.run(60000); lc.shutdown(); if (SpillableTestOperator.errorTrace != null) { logger.error("Error.", SpillableTestOperator.errorTrace); Assert.assertNull(SpillableTestOperator.errorTrace.getMessage(), SpillableTestOperator.errorTrace); } }
Source:
<code>public Optional<UsernamePasswordCredentials> extract(WebContext context) { <START> final String username = context.getRequestParameter(this.usernameParameter); <END> final String password = context.getRequestParameter(this.passwordParameter); if (username == null || password == null) { return Optional.empty(); } return Optional.of(new UsernamePasswordCredentials(username, password)); }</code><technical_language>surprised getRequestParameter return Optional :)</technical_language>

Target:
public Optional<UsernamePasswordCredentials> extract(WebContext context) { final Optional<String> username = context.getRequestParameter(this.usernameParameter); final Optional<String> password = context.getRequestParameter(this.passwordParameter); if (username.isPresent() && password.isPresent()) { return Optional.of( new UsernamePasswordCredentials(username.get(), password.get()) ); } return Optional.empty(); }
Source:
<code>public void testSystemEnvVarRef() { String[] envvar = findEnvVar(); if (envvar[0].length() == 0) { <START> fail("No environment variables found, can't pass test."); <END> return; } final String envvarValue = envvar[1]; Assert.assertNotNull("Expect non-null env var: "+envvar[0], envvarValue); final String value = "${"+envvar[0]+"}"; assertEquals(envvarValue, resolver.resolve(value)); }</code><technical_language>wow fail test here! Unfortunately,JUnit 'inconclusive' state, in C#, log a message return</technical_language>

Target:
public void testSystemEnvVarRef() { String[] envvar = findEnvVar(); if (envvar[0].length() == 0) { FoundationTestActivator.getDefault().getLog().log( new Status(IStatus.WARNING, FoundationTestActivator.PLUGIN_ID, ("No environment variables found, can't pass test."))); return; } final String envvarValue = envvar[1]; Assert.assertNotNull("Expect non-null env var: "+envvar[0], envvarValue); final String value = "${"+envvar[0]+"}"; assertEquals(envvarValue, resolver.resolve(value)); }
Source:
<code>public ValidationResult isInProcess() { StoragePoolIsoMap domainIsoMap = storageDomain.getStoragePoolIsoMapData(); if (domainIsoMap.getStatus() != null && domainIsoMap.getStatus().isStorageDomainInProcess()) { new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2, <START> String.format("$status %1$s", StorageDomainStatus.Locked)); <END> } return ValidationResult.VALID; }</code><technical_language>status in message is wrong (as check more statuses), put domain status</technical_language>

Target:
public ValidationResult isInProcess() { StoragePoolIsoMap domainIsoMap = storageDomain.getStoragePoolIsoMapData(); if (domainIsoMap.getStatus() != null && domainIsoMap.getStatus().isStorageDomainInProcess()) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2, String.format("$status %1$s", domainIsoMap.getStatus())); } return ValidationResult.VALID; }
Source:
<code>public int hashCode() { int result = super.hashCode(); <START> result = 31 * result + (scmId != null ? scmId.hashCode() : 0); <END> return result; }</code><technical_language>I agree hashCode() equals() done way, changed for PackageMaterial</technical_language>

Target:
public int hashCode() { int result = super.hashCode(); result = 31 * result + (this.getFingerprint() != null ? this.getFingerprint().hashCode() : 0); return result; }
Source:
<code>public void testSimple() throws Exception { FileUtils.copyURLToFile( getClass().getResource("main-helloWorld."+ext), new File(app, "main."+ext)); <START> MockHttpServletResponse resp = getAsServletResponse("/rest/apps/foo/main."+ext); <END> assertEquals(200, resp.getStatus()); assertEquals("Hello World!", resp.getContentAsString()); }</code><technical_language>I this /rest/script/apps, in case app controller is wrong. test in actual running geoserver script installed (from REST update) changing this</technical_language>

Target:
public void testSimple() throws Exception { FileUtils.copyURLToFile( getClass().getResource("main-helloWorld."+ext), new File(app, "main."+ext)); MockHttpServletResponse resp = getAsServletResponse("/script/apps/foo/main."+ext); assertEquals(200, resp.getStatus()); assertEquals("Hello World!", resp.getContentAsString()); }
Source:
<code>public void testRerunFailingErrorTestsWithOneRetry() throws Exception { OutputValidator outputValidator = unpack().setJUnitVersion( VERSION ).maven().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); outputValidator = unpack().setJUnitVersion( VERSION ).maven().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-DforkCount=2" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); <START> <END> outputValidator = unpack().setJUnitVersion( VERSION ).maven().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=methods" ).addGoal( "-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); outputValidator = unpack().setJUnitVersion( VERSION ).maven().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=classes" ).addGoal( "-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); }</code><technical_language>Pls debugLogging() in test. this is understand bug build system</technical_language>

Target:
public void testRerunFailingErrorTestsWithOneRetry() throws Exception { OutputValidator outputValidator = unpack().setJUnitVersion( VERSION ).maven().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).withFailure().debugLogging().executeTest() .assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); outputValidator = unpack().setJUnitVersion( VERSION ).maven().debugLogging().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-DforkCount=2" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); outputValidator = unpack().setJUnitVersion( VERSION ).maven().debugLogging().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=methods" ).addGoal( "-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); outputValidator = unpack().setJUnitVersion( VERSION ).maven().debugLogging().addGoal( "-Dsurefire.rerunFailingTestsCount=1" ).addGoal( "-Dparallel=classes" ).addGoal( "-DuseUnlimitedThreads=true" ).withFailure().executeTest().assertTestSuiteResults( 5, 1, 1, 0, 0 ); verifyFailuresOneRetryAllClasses( outputValidator ); }
Source:
<code>protected boolean addIfNotPresent(Privilege[] privileges) { ArrayList<Privilege> list = new ArrayList(); <START> list.addAll(Arrays.asList(this.privileges)); <END> boolean res = combineRecursively(list, privileges); this.privileges = new Privilege[list.size()]; list.toArray(this.privileges); return res; }</code><technical_language>iterate privileges add one, create a temporary list array (which iteration) iterate list</technical_language>

Target:
protected boolean addIfNotPresent(Privilege[] privileges) { ArrayList<Privilege> list = new ArrayList(); for (Privilege privilege : privileges) { list.add(privilege); } boolean res = combineRecursively(list, privileges); this.privileges.addAll(list); return res; }
Source:
<code>protected void postConnect(OneTimeCallback callback) throws ClientConnectionException { try { <START> final int interestedOps = SelectionKey.OP_READ; <END> reactor.wakeup(); final ReactorClient client = this; final FutureTask<SelectionKey> task = scheduleTask(new Retryable<SelectionKey>( new Callable<SelectionKey>() { @Override public SelectionKey call() throws ClosedChannelException { return channel.register(selector, interestedOps, client); } }, this.policy)); key = task.get(); } catch (InterruptedException | ExecutionException e) { throw new ClientConnectionException(e); } if (key == null) { throw new ClientConnectionException("Connection issue during post connect"); } }</code><technical_language>This variable is redundant. put OP_READ in parameter</technical_language>

Target:
protected void postConnect(OneTimeCallback callback) throws ClientConnectionException { try { final ReactorClient client = this; final FutureTask<SelectionKey> task = scheduleTask(new Retryable<SelectionKey>( new Callable<SelectionKey>() { @Override public SelectionKey call() throws ClosedChannelException { return channel.register(selector, SelectionKey.OP_READ, client); } }, this.policy)); key = task.get(); } catch (InterruptedException | ExecutionException e) { throw new ClientConnectionException(e); } if (key == null) { throw new ClientConnectionException("Connection issue during post connect"); } }
Source:
<code>private void lockFileForDeletion(File f) throws IOException, InterruptedException { assert !unlockFileCallables.containsKey(f) : f + " is already locked." ; assert Functions.isWindows(); final FileChannel channel = FileChannel.open(f.toPath(), StandardOpenOption.READ, StandardOpenOption.WRITE); <START> final FileLock lock = channel.lock(); <END> unlockFileCallables.put(f, new Callable<Void>() { public Void call() throws IOException { lock.release(); channel.close(); return null; }; }); }</code><technical_language>approach OverlappingFileLockException if lock is held JVM. unhadled random Runtime exception here. pattern is a loop tryLock(), surprisingly handle this exception</technical_language>

Target:
private void lockFileForDeletion(File f) throws IOException, InterruptedException { assert !unlockFileCallables.containsKey(f) : f + " is already locked." ; assert Functions.isWindows(); final InputStream s = new FileInputStream(f); unlockFileCallables.put(f, new Callable<Void>() { public Void call() throws IOException { s.close(); return null; }; }); }
Source:
<code>public View getView(String name) { for (View v : views) { if (v.getViewName().equals(name)) return v; <START> if (v instanceof ViewGroup) { <END> View nestedView = ((ViewGroup) v).getView(name); if (nestedView != null) { return nestedView; } } } return null; }</code><technical_language>problem this approach is Nested views a search result if is TopLevel view name. a user I expect higher priority. worth checking TopLevel views first. I vote for making a parameterizable method View getView(String name, boolean recursive) changing API calls related search. hard predict impact of defaukt behavior change</technical_language>

Target:
public View getView(String name) { for (View v : views) { if (v.getViewName().equals(name)) { return v; } } for (View v : views) { if (v instanceof ViewGroup) { View nestedView = ((ViewGroup) v).getView(name); if (nestedView != null) { return nestedView; } } } return null; }
Source:
<code>public void canFetchReadmeFileFromSpecifiedBranch() throws IOException { final MkContainer container = new MkGrizzlyContainer().next( new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"name\": \"README.md\"}") ).start(); <START> final Contents contents = new RtContents( <END> new ApacheRequest(container.home()), RtContentsTest.repo()); MatcherAssert.assertThat( contents.readme("somebranch"), Matchers.notNullValue() ); container.stop(); }</code><technical_language>I test fails container remain started port is busy. So, good practice is enclose tested code in try block stop container in finally</technical_language>

Target:
public void canFetchReadmeFileFromSpecifiedBranch() throws IOException { final MkContainer container = new MkGrizzlyContainer().next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, "{\"name\": \"README.md\"}" ) ).start(); final Contents contents = new RtContents( new ApacheRequest(container.home()), RtContentsTest.repo() ); try { MatcherAssert.assertThat( contents.readme("somebranch"), Matchers.notNullValue() ); } finally { container.stop(); } }
Source:
<code>public List<KeyRange> generateSplitRanges(int maxConcurrency) { List<KeyRange> splits = Lists.newArrayListWithCapacity(estimateSplitNum); int[] position = new int[slots.size()]; byte[] lowerBoundKey = new byte[maxKeyLength]; byte[] upperBoundKey = new byte[maxKeyLength]; int step = (int) Math.ceil(((double) estimateSplitNum) / maxConcurrency) - 1; boolean terminated = false, lowerInclusive; <START> while (true) { <END> setKey(Bound.LOWER, position, lowerBoundKey, 0, 0, position.length); lowerInclusive = ScanUtil.isKeyInclusive(Bound.LOWER, position, slots); terminated = !ScanUtil.incrementKey(slots, position, step, Bound.UPPER); if (!terminated) { setKey(Bound.UPPER, position, upperBoundKey, 0, 0, position.length); } else { for (int i=0; i<slots.size(); i++) { position[i] = slots.get(i).size() - 1; } setKey(Bound.UPPER, position, upperBoundKey, 0, 0, position.length); } KeyRange range = KeyRange.getKeyRange( Arrays.copyOf(lowerBoundKey, lowerBoundKey.length), lowerInclusive, Arrays.copyOf(upperBoundKey, upperBoundKey.length), false); splits.add(range); terminated = terminated || !ScanUtil.incrementKey(slots, position, 1, Bound.LOWER); if (terminated) break; } return splits; }</code><technical_language>Minor, this read a while(!terminated) break</technical_language>

Target:
public List<KeyRange> generateSplitRanges(int maxConcurrency) { List<KeyRange> splits = Lists.newArrayListWithCapacity(estimateSplitNum); int[] position = new int[slots.size()]; byte[] lowerBoundKey = new byte[maxKeyLength]; byte[] upperBoundKey = new byte[maxKeyLength]; int step = (int) Math.ceil(((double) estimateSplitNum) / maxConcurrency) - 1; boolean terminated = false, lowerInclusive; while (!terminated) { setKey(Bound.LOWER, position, lowerBoundKey, 0, 0, position.length); lowerInclusive = ScanUtil.isKeyInclusive(Bound.LOWER, position, slots); terminated = !ScanUtil.incrementKey(slots, position, step, Bound.UPPER); if (!terminated) { setKey(Bound.UPPER, position, upperBoundKey, 0, 0, position.length); } else { for (int i=0; i<slots.size(); i++) { position[i] = slots.get(i).size() - 1; } setKey(Bound.UPPER, position, upperBoundKey, 0, 0, position.length); } KeyRange range = KeyRange.getKeyRange( Arrays.copyOf(lowerBoundKey, lowerBoundKey.length), lowerInclusive, Arrays.copyOf(upperBoundKey, upperBoundKey.length), false); splits.add(range); terminated = terminated || !ScanUtil.incrementKey(slots, position, 1, Bound.LOWER); } return splits; }
Source:
<code>public void contextDestroyed(ServletContextEvent sce) { <START> LOGGER.info("(\"*****************************************************WPSJobListener - context destroyed, cancelling request tasks"); <END> for (Runnable runnable : RequestHandler.pool.getQueue()) { ((FutureTask) runnable).cancel(true); LOGGER.info("cancelling task"); } }</code><technical_language>Personally prefer a couple asterisks if want this stick out, this is jarring in code</technical_language>

Target:
public void contextDestroyed(ServletContextEvent sce) { for (Runnable runnable : RequestHandler.pool.getQueue()) { ((FutureTask) runnable).cancel(true); LOGGER.info("cancelling task"); } }
Source:
<code><START> public static InetAddress getLocalLoopbackAddress() { <END> try { final Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { final NetworkInterface iface = ifaces.nextElement(); if (iface.isLoopback() && iface.isUp() && !iface.isVirtual()) { final Enumeration<InetAddress> addrs = iface.getInetAddresses(); while (addrs.hasMoreElements()) { final InetAddress addr = addrs.nextElement(); if (addr instanceof Inet4Address && !addr.isMulticastAddress() && (addr.isLinkLocalAddress() || addr.isLoopbackAddress() || addr.isAnyLocalAddress())) { return addr; } } } } } catch (final Exception e) { LOG.warn("getLocalLoopbackAddress: an exception occurred while attempting to determine the local loopback address.",e); } return null; }</code><technical_language>a suggestion I this is a bit more readable Optional is a bit nicer work explicitly passing nulls around: public static Optional<InetAddress> getLocalLoopbackAddress() { try { for (NetworkInterface iface : Collections.list(NetworkInterface.getNetworkInterfaces())) { if (iface.isLoopback() && iface.isUp() && !iface.isVirtual()) { for (InetAddress addr : Collections.list(iface.getInetAddresses())) { if (addr instanceof Inet4Address && !addr.isMulticastAddress() && (addr.isLinkLocalAddress() || addr.isLoopbackAddress() || addr.isAnyLocalAddress())) { return Optional.of(addr); } } } } } catch (final Exception e) { LOG.warn("getLocalLoopbackAddress: exception occurred while attempting determine local loopback" + " address.", e); } return Optional.empty(); }</technical_language>

Target:
public static Optional<InetAddress> getLocalLoopbackAddress() { try { final List<InetAddress> loopbackAddresses = new ArrayList<>(); final Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { final NetworkInterface iface = ifaces.nextElement(); if (iface.isLoopback() && iface.isUp() && !iface.isVirtual()) { final Enumeration<InetAddress> addrs = iface.getInetAddresses(); while (addrs.hasMoreElements()) { final InetAddress addr = addrs.nextElement(); if (!addr.isMulticastAddress() && (addr.isLinkLocalAddress() || addr.isLoopbackAddress() || addr.isAnyLocalAddress())) { loopbackAddresses.add(addr); } } } } if (!loopbackAddresses.isEmpty()) { loopbackAddresses.sort(IFACE_COMPARATOR); return Optional.of(loopbackAddresses.get(0)); } } catch (final Exception e) { LOG.warn("getLocalLoopbackAddress: an exception occurred while attempting to determine the local loopback address.",e); } return Optional.empty(); }
Source:
<code>private void filterBufferAndResetBackgroundFetch(Set<StreamPartition<String>> partitions) throws InterruptedException { <START> checkIfClosed(); <END> if (partitionsFetchStarted.compareAndSet(true, false)) { scheduledExec.shutdown(); try { if (!scheduledExec.awaitTermination(EXCEPTION_RETRY_DELAY_MS, TimeUnit.MILLISECONDS)) { scheduledExec.shutdownNow(); } } catch (InterruptedException e) { log.warn(e, "InterruptedException while shutting down"); throw e; } scheduledExec = Executors.newScheduledThreadPool( fetchThreads, Execs.makeThreadFactory("KinesisRecordSupplier-Worker-%d") ); } BlockingQueue<OrderedPartitionableRecord<String, String>> newQ = new LinkedBlockingQueue<>(recordBufferSize); records.stream() .filter(x -> !partitions.contains(x.getStreamPartition())) .forEachOrdered(newQ::offer); records = newQ; partitionResources.values().forEach(x -> x.stopBackgroundFetch()); }</code><technical_language>Hmm, nice if backgroundFetchEnabled is checked in this method in callers of this method clear this method do if backgroundFetchEnabled = false</technical_language>

Target:
private void filterBufferAndResetBackgroundFetch(Set<StreamPartition<String>> partitions) throws InterruptedException { checkIfClosed(); if (backgroundFetchEnabled && partitionsFetchStarted.compareAndSet(true, false)) { scheduledExec.shutdown(); try { if (!scheduledExec.awaitTermination(EXCEPTION_RETRY_DELAY_MS, TimeUnit.MILLISECONDS)) { scheduledExec.shutdownNow(); } } catch (InterruptedException e) { log.warn(e, "InterruptedException while shutting down"); throw e; } scheduledExec = Executors.newScheduledThreadPool( fetchThreads, Execs.makeThreadFactory("KinesisRecordSupplier-Worker-%d") ); } BlockingQueue<OrderedPartitionableRecord<String, String>> newQ = new LinkedBlockingQueue<>(recordBufferSize); records.stream() .filter(x -> !partitions.contains(x.getStreamPartition())) .forEachOrdered(newQ::offer); records = newQ; partitionResources.values().forEach(x -> x.stopBackgroundFetch()); }
Source:
<code>protected Function<Filter, Predicate<DigitalExchangePageModelDto>> getPredicates() { return (filter) -> { switch (filter.getAttribute()) { case CODE: return p -> FilterUtils.filterString(filter, p::getCode); case DESCRIPTION: return p -> FilterUtils.filterString(filter, p::getDescr); case MAIN_FRAME: return p -> FilterUtils.filterInt(filter, p::getMainFrame); case PLUGIN_CODE: return p -> FilterUtils.filterString(filter, p::getPluginCode); case TEMPLATE: return p -> FilterUtils.filterString(filter, p::getTemplate); case DIGITAL_EXCHANGE: return p -> FilterUtils.filterString(filter, p::getDigitalExchange); } <START> return null; <END> }; }</code><technical_language>A improvement is move this return null a default case</technical_language>

Target:
protected Function<Filter, Predicate<DigitalExchangePageModelDto>> getPredicates() { return (filter) -> { switch (filter.getAttribute()) { case CODE: return p -> FilterUtils.filterString(filter, p::getCode); case DESCRIPTION: return p -> FilterUtils.filterString(filter, p::getDescr); case MAIN_FRAME: return p -> FilterUtils.filterInt(filter, p::getMainFrame); case PLUGIN_CODE: return p -> FilterUtils.filterString(filter, p::getPluginCode); case TEMPLATE: return p -> FilterUtils.filterString(filter, p::getTemplate); case DIGITAL_EXCHANGE: return p -> FilterUtils.filterString(filter, p::getDigitalExchange); default: return null; } }; }
Source:
<code>public final Iterable<String> iterate() { <START> return null; <END> }</code><technical_language>here, return NULL (very bad practice), throw UnsupportedOperationException instead</technical_language>

Target:
public final Iterable<String> iterate() { throw new UnsupportedOperationException(); }
Source:
<code>private Color createColor() { Sequence sequence = getValue().getSequence(); if (sequence == null) { <START> return Color.BLUE; <END> } else { return SequenceColor.getColor(sequence); } }</code><technical_language>Default color a constant</technical_language>

Target:
private Color createColor() { Sequence sequence = getValue().getSequence(); if (sequence == null) { return DEFAULT_COLOR; } else { return SequenceColor.getColor(sequence); } }
Source:
<code>protected boolean unregisterLibvirtSecrets(StorageDomain storageDomain, Guid vdsId) { Provider provider = getProviderDao().get(Guid.createGuidFromString(storageDomain.getStorage())); VDS vds = getVdsDao().get(vdsId); List<LibvirtSecret> libvirtSecrets = getLibvirtSecretDao().getAllByProviderId(provider.getId()); List<Guid> libvirtSecretsUuids = Entities.getIds(libvirtSecrets); if (!libvirtSecrets.isEmpty()) { VDSReturnValue returnValue; try { returnValue = Backend.getInstance().getResourceManager().RunVdsCommand( VDSCommandType.UnregisterLibvirtSecrets, new UnregisterLibvirtSecretsVDSParameters(vdsId, libvirtSecretsUuids)); } catch (RuntimeException e) { log.error("Failed to unregister libvirt secret for storage domain on vds {}. Error: {}", storageDomain.getName(), vds.getName(), e.getMessage()); log.debug("Exception", e); <START> return false; <END> } if (!returnValue.getSucceeded()) { addMessageToAuditLog(AuditLogType.FAILED_TO_UNREGISTER_LIBVIRT_SECRET, storageDomain.getName(), vds.getName()); log.error("Failed to unregister libvirt secret for storage domain on vds {}.", storageDomain.getName(), vds.getName()); return false; } } return true; }</code><technical_language>adding audit log</technical_language>

Target:
protected boolean unregisterLibvirtSecrets(StorageDomain storageDomain, Guid vdsId) { Provider provider = getProviderDao().get(Guid.createGuidFromString(storageDomain.getStorage())); VDS vds = getVdsDao().get(vdsId); List<LibvirtSecret> libvirtSecrets = getLibvirtSecretDao().getAllByProviderId(provider.getId()); List<Guid> libvirtSecretsUuids = Entities.getIds(libvirtSecrets); if (!libvirtSecrets.isEmpty()) { VDSReturnValue returnValue; try { returnValue = Backend.getInstance().getResourceManager().RunVdsCommand( VDSCommandType.UnregisterLibvirtSecrets, new UnregisterLibvirtSecretsVDSParameters(vdsId, libvirtSecretsUuids)); } catch (RuntimeException e) { addMessageToAuditLog(AuditLogType.FAILED_TO_UNREGISTER_LIBVIRT_SECRET, storageDomain.getName(), vds.getName()); log.error("Failed to unregister libvirt secret for storage domain on vds {}. Error: {}", storageDomain.getName(), vds.getName(), e.getMessage()); log.debug("Exception", e); return false; } if (!returnValue.getSucceeded()) { addMessageToAuditLog(AuditLogType.FAILED_TO_UNREGISTER_LIBVIRT_SECRET, storageDomain.getName(), vds.getName()); log.error("Failed to unregister libvirt secret for storage domain on vds {}.", storageDomain.getName(), vds.getName()); return false; } } return true; }
Source:
<code>private String writeGroupMergeInfo( final Metadata md, final Group group, final List<StoreKey> contributingMembers, final String path ) throws IndyWorkflowException { logger.trace( "Start write .info file based on if the cache exists for group of members in path. ", group.getKey(), contributingMembers, path ); final Transfer mergeInfoTarget = fileManager.getTransfer( group, path + GroupMergeHelper.MERGEINFO_SUFFIX ); <START> logger.trace( ".info file not found for of members in path {}", group.getKey(), contributingMembers, path ); <END> logger.trace( "metadata merge info not cached for group of members in path {}, will regenerate.", group.getKey(), contributingMembers, path ); String metaMergeInfo = helper.generateMergeInfoFromKeys( contributingMembers ); logger.trace( "Metadata merge info for of members in path is {}", group.getKey(), contributingMembers, path, metaMergeInfo ); helper.writeMergeInfo( metaMergeInfo, group, path ); logger.trace( ".info file regenerated for group of members in path. Full path: {}", group.getKey(), contributingMembers, path, mergeInfoTarget.getDetachedFile() ); return metaMergeInfo; }</code><technical_language>confused here. If "mergeInfoTarget" is missing, trace this log</technical_language>

Target:
private String writeGroupMergeInfo( final Metadata md, final Group group, final List<StoreKey> contributingMembers, final String path ) throws IndyWorkflowException { logger.trace( "Start write .info file based on if the cache exists for group of members in path. ", group.getKey(), contributingMembers, path ); final Transfer mergeInfoTarget = fileManager.getTransfer( group, path + GroupMergeHelper.MERGEINFO_SUFFIX ); logger.trace( "Regenerating metadata merge info for group of members in path {}", group.getKey(), contributingMembers, path ); String metaMergeInfo = helper.generateMergeInfoFromKeys( contributingMembers ); logger.trace( "Metadata merge info for of members in path is {}", group.getKey(), contributingMembers, path, metaMergeInfo ); helper.writeMergeInfo( metaMergeInfo, group, path ); logger.trace( ".info file regenerated for group of members in path. Full path: {}", group.getKey(), contributingMembers, path, mergeInfoTarget.getDetachedFile() ); return metaMergeInfo; }
Source:
<code>private static String getCPUInfo() throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/cpuinfo")); String line; Map<String, String> output = new HashMap<>(); while ((line = bufferedReader.readLine()) != null) { String[] data = line.split(":"); if (data.length > 1) { String key = data[0].trim(); <START> if (key.equals("model name")) { <END> bufferedReader.close(); return data[1].trim(); } } } bufferedReader.close(); return "N/A"; }</code><technical_language>thinking avoid work this out record number of logical cores well. I guess stable of this counting number of model name instances. machine is siblings, idk if standard, esp android</technical_language>

Target:
private static HashMap getCPUInfo() throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/cpuinfo")); String line; HashMap output = new HashMap(); while ((line = bufferedReader.readLine()) != null) { String[] data = line.split(":"); if (data.length > 1) { String key = data[0].trim(); if (key.equals("model name")) { output.put(key, data[1].trim()); } } } bufferedReader.close(); int cores = Runtime.getRuntime().availableProcessors(); output.put("cores", cores); return output; }
Source:
<code>public TriggerResult onEventTime(long timestamp, W window, TriggerContext ctx) throws Exception { this.nestedTrigger.onEventTime(timestamp, window, ctx); <START> return TriggerResult.FIRE; <END> }</code><technical_language>I this logic onProcessingTime()</technical_language>

Target:
public TriggerResult onEventTime(long timestamp, W window, TriggerContext ctx) throws Exception { TriggerResult triggerResult = this.nestedTrigger.onEventTime(timestamp, window, ctx); if (shouldClearOnTimeout) { this.clear(window, ctx); } return triggerResult.isPurge() ? TriggerResult.FIRE_AND_PURGE : TriggerResult.FIRE; }
Source:
<code>private DocumentCollection getCollection(String collectionId) { if (collection == null) { List<DocumentCollection> collectionList = documentClient .queryCollections( getDatabase().getSelfLink(), "SELECT * FROM root r WHERE r.id='" + collectionId + "'", null).getQueryIterable().toList(); if (collectionList.size() > 0) { collection = collectionList.get(0); } else { try { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(collectionId); collection = documentClient.createCollection( getDatabase().getSelfLink(), collectionDefinition, null).getResource(); } catch (DocumentClientException e) { <START> e.printStackTrace(); <END> } } } return collection; }</code><technical_language>this throw exception error? Instead of printing message</technical_language>

Target:
private DocumentCollection getCollection(String collectionId) throws DocumentClientException { if (collection == null) { List<DocumentCollection> collectionList = documentClient .queryCollections(getDatabase().getSelfLink(), "SELECT * FROM root r WHERE r.id='" + collectionId + "'", null) .getQueryIterable() .toList(); if (collectionList.size() > 0) { collection = collectionList.get(0); } else { try { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(collectionId); collection = documentClient .createCollection(getDatabase().getSelfLink(), collectionDefinition, null) .getResource(); } catch (DocumentClientException e) { e.printStackTrace(System.err); throw e; } } } return collection; }
Source:
<code>private ParserResult mergeImportResults(List<ImportFormatReader.UnknownFormatImport> imports) { BibDatabase resultDatabase = new BibDatabase(); ParserResult result = new ParserResult(resultDatabase); for (ImportFormatReader.UnknownFormatImport importResult : imports) { if (importResult == null) { continue; } ParserResult parserResult = importResult.parserResult; <START> new BibDatabaseMerger().merge(resultDatabase, parserResult.getDatabase()); <END> if (ImportFormatReader.BIBTEX_FORMAT.equals(importResult.format)) { result.getMetaData().merge( parserResult.getMetaData(), importResult.parserResult.getFile().map(File::getName).orElse("unknown"), parserResult.getDatabase().getEntries()); } } UpdateField.setAutomaticFields(resultDatabase.getEntries(), Globals.prefs.getOwnerPreferences(), Globals.prefs.getTimestampPreferences()); return result; }</code><technical_language>merge method checks for duplicates etc, this is done in import dialog user decide overwrite duplication check. This is behavior keep, i.e. need add entries db other one</technical_language>

Target:
private ParserResult mergeImportResults(List<ImportFormatReader.UnknownFormatImport> imports) { BibDatabase resultDatabase = new BibDatabase(); ParserResult result = new ParserResult(resultDatabase); for (ImportFormatReader.UnknownFormatImport importResult : imports) { if (importResult == null) { continue; } ParserResult parserResult = importResult.parserResult; resultDatabase.insertEntries(parserResult.getDatabase().getEntries()); if (ImportFormatReader.BIBTEX_FORMAT.equals(importResult.format)) { new DatabaseMerger().mergeMetaData( result.getMetaData(), parserResult.getMetaData(), importResult.parserResult.getFile().map(File::getName).orElse("unknown"), parserResult.getDatabase().getEntries()); } } UpdateField.setAutomaticFields(resultDatabase.getEntries(), Globals.prefs.getOwnerPreferences(), Globals.prefs.getTimestampPreferences()); return result; }
Source:
<code>public void returnsProperResponseCodeOnNoContentLength() throws Exception { final ByteArrayOutputStream output = new ByteArrayOutputStream(); final String text = "Say hello!"; try (ServerSocket server = new ServerSocket(0)) { new Thread( new Runnable() { @Override public void run() { try { new BkBasic(new TkText("411 Test")).accept( server.accept() ); } catch (final IOException exception) { throw new IllegalStateException(exception); } } } ).start(); try (Socket socket = new Socket( server.getInetAddress(), server.getLocalPort() ) ) { socket.getOutputStream().write( new JoinedText( BkBasicTest.CRLF, BkBasicTest.POST, BkBasicTest.HOST, "", text <START> ).asString().getBytes() <END> ); final InputStream input = socket.getInputStream(); final byte[] buffer = new byte[4096]; for (int count = input.read(buffer); count != -1; count = input.read(buffer)) { output.write(buffer, 0, count); } } } MatcherAssert.assertThat( output.toString(), Matchers.containsString("HTTP/1.1 411 Length Required") ); }</code><technical_language>@Serranya cactoos BytesOf WDYT</technical_language>

Target:
public void returnsProperResponseCodeOnNoContentLength() throws Exception { final ByteArrayOutputStream output = new ByteArrayOutputStream(); final String text = "Say hello!"; try (ServerSocket server = new ServerSocket(0)) { new Thread( new Runnable() { @Override public void run() { try { new BkBasic(new TkText("411 Test")).accept( server.accept() ); } catch (final IOException exception) { throw new IllegalStateException(exception); } } } ).start(); try (Socket socket = new Socket( server.getInetAddress(), server.getLocalPort() ) ) { socket.getOutputStream().write( new BytesOf( new JoinedText( BkBasicTest.CRLF, BkBasicTest.POST, BkBasicTest.HOST, "", text ) ).asBytes() ); final InputStream input = socket.getInputStream(); final byte[] buffer = new byte[4096]; for (int count = input.read(buffer); count != -1; count = input.read(buffer)) { output.write(buffer, 0, count); } } } MatcherAssert.assertThat( output.toString(), Matchers.containsString("HTTP/1.1 411 Length Required") ); }
Source:
<code>public void bulkOutputCallerTest() throws Exception { String endpointState = "{\"next\":"+1+"}"; String workUnit = "{\"max\":"+6+"}"; OutputCallerImpl caller = new OutputCallerImpl(new JacksonHandle(apiObj)); Stream<InputStream> result = caller.streamCall(IOTestUtil.db, IOTestUtil.asInputStream(endpointState), caller.newSessionState(), IOTestUtil.asInputStream(workUnit)); InputStream[] resultArray = result.toArray(size -> new InputStream[size]); assertNotNull(resultArray); assertTrue(resultArray.length == count); List<String> list = new ArrayList<>(); for(int i=0;i<resultArray.length;i++) { assertNotNull(resultArray[i]); list.add(IOTestUtil.mapper.readValue(resultArray[i], ObjectNode.class).toString()); } OutputEndpointImpl.BulkOutputCaller bulkCaller = OutputEndpoint.on(IOTestUtil.db, new JacksonHandle(apiObj)).bulkCaller(); bulkCaller.setEndpointState(new ByteArrayInputStream(endpointState.getBytes())); bulkCaller.setWorkUnit(new ByteArrayInputStream(workUnit.getBytes())); bulkCaller.forEachOutput(i-> { try { assertTrue(list.contains(IOTestUtil.mapper.readValue(i, ObjectNode.class).toString())); } catch (IOException e) { e.printStackTrace(); } }); <START> bulkCaller.awaitCompletion(); <END> }</code><technical_language>sense confirm forEachOutput() executed expected number of times? is, lambda increment a counter assertion counter follow completion</technical_language>

Target:
public void bulkOutputCallerTest() throws Exception { String endpointState = "{\"next\":"+1+"}"; String workUnit = "{\"max\":"+6+"}"; OutputCallerImpl caller = new OutputCallerImpl(new JacksonHandle(apiObj)); Stream<InputStream> result = caller.streamCall(IOTestUtil.db, IOTestUtil.asInputStream(endpointState), caller.newSessionState(), IOTestUtil.asInputStream(workUnit)); InputStream[] resultArray = result.toArray(size -> new InputStream[size]); assertNotNull(resultArray); assertTrue(resultArray.length-1 == count); List<String> list = new ArrayList<>(); for(int i=1;i<resultArray.length;i++) { assertNotNull(resultArray[i]); list.add(IOTestUtil.mapper.readValue(resultArray[i], ObjectNode.class).toString()); } String workUnit2 = "{\"max\":"+3+"}"; OutputEndpointImpl.BulkOutputCaller bulkCaller = OutputEndpoint.on(IOTestUtil.db, new JacksonHandle(apiObj)).bulkCaller(); bulkCaller.setEndpointState(new ByteArrayInputStream(endpointState.getBytes())); bulkCaller.setWorkUnit(new ByteArrayInputStream(workUnit2.getBytes())); class Output { int counter =0; } Output output = new Output(); bulkCaller.forEachOutput(i-> { try { assertTrue(list.contains(IOTestUtil.mapper.readValue(i, ObjectNode.class).toString())); output.counter++; } catch (IOException e) { e.printStackTrace(); } }); bulkCaller.awaitCompletion(); assertTrue(output.counter == count); }
Source:
<code>public Serializable getId() { if ( id == null ) { if ( type == null ) { throw log.incompleteEntityInfo( null, null ); } else { <START> throw log.incompleteEntityInfo( type, id ); <END> } } return id; }</code><technical_language>I remove surrounding if, safe :]</technical_language>

Target:
public Serializable getId() { if ( id == null ) { throw log.incompleteEntityInfo( type, id ); } return id; }
Source:
<code>public void flush() { if (!statement.trim().isEmpty()) { <START> statements.add(statement.trim()); <END> } statement = ""; }</code><technical_language>Reason for trimming</technical_language>

Target:
public void flush() { if (!statement.trim().isEmpty()) { statements.add(removeLeadingTrailingNewLines(statement)); } statement = ""; }
Source:
<code>public String getActionProviders(HttpServletRequest request, HttpServletResponse response) throws SecurityServiceException { HttpSession session = httpSessionFactory.getOrCreateSession(request); Object token = ((SecurityTokenHolder) session.getAttribute(SecurityConstants.SECURITY_TOKEN_KEY)) .getPrincipals(); SessionToken sessionToken = new SessionToken(token, session.getId(), "127.0.0.1"); Subject subject = securityManager.getSubject(sessionToken); Map<String, Object> subjectMap = new HashMap<>(); subjectMap.put("http_request", request); subjectMap.put("http_response", response); subjectMap.put(SecurityConstants.SECURITY_SUBJECT, subject); Map<String, String> actionProperties = new HashMap<>(); for (ActionProvider actionProvider : logoutActionProviders) { Action action = actionProvider.getAction(subjectMap); if (action != null) { String displayName = SubjectUtils.getName(subject, "", true); actionProperties.put("title", action.getTitle()); actionProperties.put("auth", displayName); actionProperties.put("description", action.getDescription()); StringBuilder urlBuilder = new StringBuilder(action.getUrl().toString()); String referer = request.getHeader("Referer"); if (!StringUtils.isEmpty(referer)) { String[] parts = referer.split("\\?prevurl="); if (parts.length > 1) { String previousUrl = parts[1]; <START> urlBuilder.append("?prevurl="); <END> urlBuilder.append(previousUrl); } } actionProperties.put("url", urlBuilder.toString()); } } return GSON.toJson(actionProperties); }</code><technical_language>service query parameter? Admin UI Intrigue instead of prevurl</technical_language>

Target:
public String getActionProviders(HttpServletRequest request, HttpServletResponse response) throws SecurityServiceException { HttpSession session = httpSessionFactory.getOrCreateSession(request); Object token = ((SecurityTokenHolder) session.getAttribute(SecurityConstants.SECURITY_TOKEN_KEY)) .getPrincipals(); SessionToken sessionToken = new SessionToken(token, session.getId(), "127.0.0.1"); Subject subject = securityManager.getSubject(sessionToken); Map<String, Object> subjectMap = new HashMap<>(); subjectMap.put("http_request", request); subjectMap.put("http_response", response); subjectMap.put(SecurityConstants.SECURITY_SUBJECT, subject); Map<String, String> actionProperties = new HashMap<>(); for (ActionProvider actionProvider : logoutActionProviders) { Action action = actionProvider.getAction(subjectMap); if (action != null) { String displayName = SubjectUtils.getName(subject, "", true); actionProperties.put("title", action.getTitle()); actionProperties.put("auth", displayName); actionProperties.put("description", action.getDescription()); actionProperties.put("url", action.getUrl().toString()); } } return GSON.toJson(actionProperties); }