auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private ByteBuffer parseCBPayLoad(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; pcapPacketHeader.getInt(); long packetLength = ConversionHelper.unsignedIntToLong(blockLength); SeekableByteChannel fFileChannel = getFileChannel(); if (fFileChannel.size() - fFileChannel.position() < packetLength) { throw new BadPcapFileException(String.format("%04x", packetLength) + " is causing buffer overrun."); } if (blockLength > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", blockLength) + " packet length is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) packetLength - 12); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); int payLoad = fFileChannel.read(pcapPacketData); if (payLoad == 0) { throw new BadPcapFileException(String.format("%04x", payLoad) + " is a bad payload."); } pcapPacketData.flip(); fFileChannel.position(fFileChannel.position() + blockLength - 12); return pcapPacketData; }

Target:
private ByteBuffer parseCBPayLoad(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; pcapPacketHeader.getInt(); long packetLength = ConversionHelper.unsignedIntToLong(blockLength); SeekableByteChannel fileChannel = getFileChannel(); if (fileChannel.size() - fileChannel.position() < packetLength) { throw new BadPcapFileException(String.format("%04x", packetLength) + " is causing buffer overrun."); } if (blockLength > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", blockLength) + " packet length is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) packetLength - 12); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); int payLoad = fileChannel.read(pcapPacketData); if (payLoad == 0) { throw new BadPcapFileException(String.format("%04x", payLoad) + " is a bad payload."); } pcapPacketData.flip(); fileChannel.position(fileChannel.position() + blockLength - 12); return pcapPacketData; }
Source:
public void testOSGIDebugCommand() throws CarbonToolsIntegrationTestException, IOException { String[] cmdArray; String expectedString = "OSGi debugging has been enabled with options:"; boolean isFoundTheMessage = false; InputStream is = null; InputStreamReader isr = null; int timeout = 30000; BufferedReader br = null; if (CarbonCommandToolsUtil.isCurrentOSWindows()) { cmdArray = new String[] {"cmd.exe", "/c", "wso2server.bat", "-DosgiDebugOptions", "-DportOffset=1"}; commandDirectory = CarbonCommandToolsUtil.getCarbonHome(context) + File.separator + "bin"; } else { cmdArray = new String[] {"sh", "wso2server.sh", "-DosgiDebugOptions", "-DportOffset=1"}; commandDirectory = CarbonCommandToolsUtil.getCarbonHome(context) + "/bin"; } try { process = CarbonCommandToolsUtil.runScript(commandDirectory, cmdArray); String line; long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime) < timeout) { is = process.getInputStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); if (br != null) { line = br.readLine(); if (line.contains(expectedString)) { log.info("found the string " + expectedString + " in line " + line); isFoundTheMessage = true; break; } } } } finally { if (is != null) { is.close(); } if (isr != null) { isr.close(); } if (br != null) { br.close(); } } CarbonCommandToolsUtil.isServerStartedUp(context, portOffset); Assert.assertTrue(isFoundTheMessage, "Java file not created successfully"); }

Target:
public void testOSGIDebugCommand() throws CarbonToolsIntegrationTestException, IOException { String[] cmdArray; String expectedString = "OSGi debugging has been enabled with options:"; boolean isFoundTheMessage = false; InputStream is = null; int timeout = 30000; BufferedReader br = null; if ((CarbonCommandToolsUtil.getCurrentOperatingSystem(). contains(OperatingSystems.WINDOWS.name().toLowerCase())) ) { cmdArray = new String[] {"cmd.exe", "/c", "wso2server.bat", "-DosgiDebugOptions", "-DportOffset=1"}; commandDirectory = CarbonCommandToolsUtil.getCarbonHome(context) + File.separator + "bin"; } else { cmdArray = new String[] {"sh", "wso2server.sh", "-DosgiDebugOptions", "-DportOffset=1"}; commandDirectory = CarbonCommandToolsUtil.getCarbonHome(context) + "/bin"; } try { process = CarbonCommandToolsUtil.runScript(commandDirectory, cmdArray); String line; long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime) < timeout) { is = process.getInputStream(); br = new BufferedReader(new InputStreamReader(is, "UTF-8")); if (br != null) { line = br.readLine(); if (line.contains(expectedString)) { log.info("found the string " + expectedString + " in line " + line); isFoundTheMessage = true; break; } } } } finally { if (is != null) { is.close(); } if (br != null) { br.close(); } } CarbonCommandToolsUtil.isServerStartedUp(context, portOffset); Assert.assertTrue(isFoundTheMessage, "Java file not created successfully"); }
Source:
public void refreshAllUsers() { final Map<String, List<DbUser>> usersPerAuthz = new HashMap<>(); final Map<String, List<DbGroup>> groupsPerAuthz = new HashMap<>(); for (DbGroup dbGroup : DbFacade.getInstance().getDbGroupDao().getAll()) { MultiValueMapUtils.addToMap(dbGroup.getDomain(), dbGroup, groupsPerAuthz); } for (DbUser dbUser : DbFacade.getInstance().getDbUserDao().getAll()) { MultiValueMapUtils.addToMap(dbUser.getDomain(), dbUser, usersPerAuthz); } Set<String> authzNames = new HashSet<String>() { { addAll(usersPerAuthz.keySet()); addAll(groupsPerAuthz.keySet()); } }; List<DbUser> refreshedUsers = new ArrayList<>(); for (String authzName : authzNames) { refreshedUsers.addAll(refreshAllUsers(EngineExtensionsManager.getInstance().getExtensionByName(authzName), usersPerAuthz.get(authzName), groupsPerAuthz.get(authzName))); } for (DbUser dbUser : refreshedUsers) { DbFacade.getInstance().getDbUserDao().update(dbUser); } }

Target:
public void refreshAllUsers() { sync.refreshAllUsers(DbFacade.getInstance().getDbUserDao().getAll()); }
Source:
LogMessageContext(String prefix) { this.appendSubject = getSubject(prefix, "append"); this.consumeSubject = getSubject(prefix, "read"); this.resetSubject = getSubject(prefix, "reset"); this.backupSubject = getSubject(prefix, "backup"); }

Target:
LogMessageContext(String prefix) { this.appendSubject = getSubject(prefix, "append"); this.consumeSubject = getSubject(prefix, "consume"); this.resetSubject = getSubject(prefix, "reset"); this.backupSubject = getSubject(prefix, "backup"); }
Source:
protected void onPause() { super.onPause(); mMap.setOnMapLoadedCallback(null); if (mMap != null && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { mMap.setMyLocationEnabled(false); } }

Target:
protected void onPause() { super.onPause(); if (mMap != null) { mMap.setOnMapLoadedCallback(null); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(false); } } }
Source:
public ElasticsearchRecordCursor(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConnectorConfig config, ElasticsearchSplit split) { this.columnHandles = requireNonNull(columnHandles, "columnHandle is null"); this.maxHits = requireNonNull(config, "config is null").getMaxHits(); this.timeout = config.getRequestTimeout(); for (int i = 0; i < columnHandles.size(); i++) { jsonPathToIndex.put(columnHandles.get(i).getColumnJsonPath(), i); } this.builder = new ElasticsearchQueryBuilder(columnHandles, config, split); this.searchHits = sendElasticQuery(builder).iterator(); }

Target:
public ElasticsearchRecordCursor(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConnectorConfig config, ElasticsearchSplit split) { requireNonNull(columnHandles, "columnHandle is null"); requireNonNull(config, "config is null"); this.columnHandles = columnHandles; this.maxHits = config.getMaxHits(); this.timeout = config.getRequestTimeout(); for (int i = 0; i < columnHandles.size(); i++) { jsonPathToIndex.put(columnHandles.get(i).getColumnJsonPath(), i); } this.builder = new ElasticsearchQueryBuilder(columnHandles, config, split); this.searchHits = sendElasticQuery(builder).iterator(); }
Source:
public void setTreeFilter(TreeFilter filter) { super.setTreeFilter(filter); if (filter instanceof FollowFilter) { FollowFilter followFilter = (FollowFilter) filter; RenameCallback renameCallback = followFilter.getRenameCallback(); if (renameCallback == null) { followFilter.setRenameCallback(callback); } } }

Target:
public void setTreeFilter(TreeFilter filter) { super.setTreeFilter(filter); if (filter instanceof FollowFilter) { FollowFilter followFilter = (FollowFilter) filter; RenameCallback renameCallback = followFilter.getRenameCallback(); if (renameCallback == null) followFilter.setRenameCallback(callback); } }
Source:
public void saveRunQC(RunQC runQC) throws IOException { if (runQcStore != null) { runQcStore.save(runQC); } else { throw new IOException("No runQcStore available. Check that it has been declared in the Spring config."); } }

Target:
public long saveRunQC(RunQC runQC) throws IOException { if (runQcStore != null) { Long runQcId = runQcStore.save(runQC); if (runAlertManager != null) runAlertManager.update(runQC.getRun()); return runQcId; } else { throw new IOException("No runQcStore available. Check that it has been declared in the Spring config."); } }
Source:
public Object visit(ASTElement node, Object data) { if (APEX_PAGE.equalsIgnoreCase(node.getName())) { List<ASTAttribute> attribs = node.findChildrenOfType(ASTAttribute.class); boolean controller = false; boolean action = false; boolean isEl = false; ASTElExpression valToReport = null; for (ASTAttribute attr : attribs) { switch (attr.getName().toLowerCase()) { case "action": action = true; break; case "controller": controller = true; break; default: break; } if (action) { ASTElExpression value = attr.getFirstDescendantOfType(ASTElExpression.class); if (value != null) { if (doesElContainIdentifiers(value)) { isEl = true; valToReport = value; } } } } if (controller && isEl && valToReport != null) { addViolation(data, valToReport); } } return super.visit(node, data); }

Target:
public Object visit(ASTElement node, Object data) { if (APEX_PAGE.equalsIgnoreCase(node.getName())) { List<ASTAttribute> attribs = node.findChildrenOfType(ASTAttribute.class); boolean controller = false; boolean isEl = false; ASTElExpression valToReport = null; for (ASTAttribute attr : attribs) { switch (attr.getName().toLowerCase()) { case "action": ASTElExpression value = attr.getFirstDescendantOfType(ASTElExpression.class); if (value != null) { if (doesElContainIdentifiers(value)) { isEl = true; valToReport = value; } } break; case "controller": controller = true; break; default: break; } } if (controller && isEl && valToReport != null) { addViolation(data, valToReport); } } return super.visit(node, data); }
Source:
public void remove() { super.remove(); bPlayer.addCooldown(this); MultiAbilityManager.unbindMultiAbility(player); flying.remove(player.getUniqueId()); if (player.isOnline() && !player.isDead()) { player.eject(); } ProjectKorra.flightHandler.removeInstance(player, "FlightMultiAbility"); player.setGliding(hadGlide); }

Target:
public void remove() { super.remove(); bPlayer.addCooldown(this); MultiAbilityManager.unbindMultiAbility(player); flying.remove(player.getUniqueId()); if (player.isOnline() && !player.isDead()) { player.eject(); } ProjectKorra.flightHandler.removeInstance(player, ID); player.setGliding(hadGlide); }
Source:
private static void parseAppStanza(ClientInfo.Builder builder, String stanza) { if (StringUtils.isBlank(stanza)) { return; } String[] components = stanza.split("/"); if (components.length == 2) { if (!components[0].matches(DIGITS_REGEXP)) { builder.withAppName(parseString(components[0])); } builder.withAppVersion(parseInteger(components[1])).build(); } else if (components.length == 1) { if (components[0].matches(DIGITS_REGEXP)) { builder.withAppVersion(parseInteger(components[0])); } else { builder.withAppName(parseString(components[0])); } } }

Target:
private static void parseAppStanza(ClientInfo.Builder builder, String stanza) { if (StringUtils.isBlank(stanza)) { return; } String[] components = stanza.split("/"); if (components.length == 2) { if (!components[0].matches(DIGITS_REGEXP)) { builder.withAppName(parseString(components[0])); } builder.withAppVersion(parseInteger(components[1])); } else if (components.length == 1) { if (components[0].matches(DIGITS_REGEXP)) { builder.withAppVersion(parseInteger(components[0])); } else { builder.withAppName(parseString(components[0])); } } }
Source:
public Adapter getContentAdapter() { if (adapter == null) { adapter = new AdapterImpl() { @Override public void notifyChanged(final Notification notification) { int type = notification.getEventType(); switch (type) { case Notification.ADD: case Notification.ADD_MANY: case Notification.REMOVE: case Notification.REMOVE_MANY: refreshChildren(); break; case Notification.SET: break; } } }; } return adapter; }

Target:
public Adapter getContentAdapter() { if (null == adapter) { adapter = new AdapterImpl() { @Override public void notifyChanged(final Notification notification) { int type = notification.getEventType(); switch (type) { case Notification.ADD: case Notification.ADD_MANY: case Notification.REMOVE: case Notification.REMOVE_MANY: refreshChildren(); break; case Notification.SET: break; } } }; } return adapter; }
Source:
public static List<Class<?>> getSuperInterfaces(Class clazz) { ArrayList<Class<?>> result = new ArrayList<Class<?>>(); addImplementedSuperInterfaces(clazz, result); return result; }

Target:
public static List<Class<?>> getSuperInterfaces(Class clazz) { ArrayList<Class<?>> result = new ArrayList<>(); addImplementedSuperInterfaces(clazz, result); return result; }
Source:
private Object getVmsFullInfoFromExternalProvider() { try { return runVdsCommand(VDSCommandType.GetVmsFullInfoFromExternalProvider, buildGetRemoteVmsInfoParameters()).getReturnValue(); } catch (RuntimeException e) { if (!(e instanceof IllegalArgumentException)) { logFailureToGetVms(); } throw e; } }

Target:
private void getVmsFullInfoFromExternalProvider() { try { setReturnValue(runVdsCommand(VDSCommandType.GetVmsFullInfoFromExternalProvider, buildGetRemoteVmsInfoParameters()).getReturnValue()); } catch (RuntimeException e) { if (!(e instanceof IllegalArgumentException)) { logFailureToGetVms(); } throw e; } }
Source:
public SChannelInput(final SynchronousQueue<Object> cell, final SChannel channel) { this.cell = cell; this.channel = channel; if (VmSettings.ACTOR_TRACING | VmSettings.REPLAY) { numReads = new AtomicInteger(0); } else { numReads = null; } }

Target:
public SChannelInput(final SynchronousQueue<Object> cell, final SChannel channel) { this.cell = cell; this.channel = channel; }
Source:
public JsonElement serialize(Predicate src, Type typeOfSrc, JsonSerializationContext context) { if (src == null) return null; if (src instanceof StatePredicate) { JsonElement clause = gson.toJsonTree( ((StatePredicate) src).getCondition().getClause(), TriggerClause.class); JsonObject json = new JsonObject(); json.add("condition", clause); json.addProperty("triggersWhen", ((StatePredicate) src).getTriggersWhen().name()); json.addProperty("eventSource", src.getEventSource().name()); return json; }else { JsonObject ret = gson.toJsonTree(src).getAsJsonObject(); ret.addProperty("eventSource", src.getEventSource().name()); return ret; } }

Target:
public JsonElement serialize(Predicate src, Type typeOfSrc, JsonSerializationContext context) { if (src == null) return null; if (src instanceof StatePredicate) { JsonElement clause = gson.toJsonTree( ((StatePredicate) src).getCondition().getClause(), TriggerClause.class); JsonObject ret = new JsonObject(); ret.add("condition", clause); ret.addProperty("triggersWhen", ((StatePredicate) src).getTriggersWhen().name()); ret.addProperty("eventSource", src.getEventSource().name()); return ret; } else { JsonObject ret = gson.toJsonTree(src).getAsJsonObject(); ret.addProperty("eventSource", src.getEventSource().name()); return ret; } }
Source:
protected int run() throws Exception { boolean errorOccurred = false; final HashSet<String> hs = new HashSet<String>(); hs.addAll(views); ViewOptionHandler voh = new ViewOptionHandler(null, null, null); for(String view_s : hs) { View view = null; try { try { view = voh.getView(view_s); view.checkPermission(View.DELETE); } catch (Exception e) { stderr.println(e.getMessage()); errorOccurred = true; continue; } ViewGroup group = view.getOwner(); if (!group.canDelete(view)) { stderr.format("%s does not allow to delete '%s' view\n", group.getDisplayName(), view.getViewName() ); errorOccurred = true; continue; } group.deleteView(view); } catch (Exception e) { stderr.format("Unexpected exception occurred during deletion of view '%s': %s\n", view == null ? "(null)" : view.getViewName(), e.getMessage() ); errorOccurred = true; continue; } } return errorOccurred ? -1 : 0; }

Target:
protected int run() throws Exception { boolean errorOccurred = false; final HashSet<String> hs = new HashSet<String>(); hs.addAll(views); ViewOptionHandler voh = new ViewOptionHandler(null, null, null); for(String view_s : hs) { View view = null; try { try { view = voh.getView(view_s); if (view == null) { stderr.println("user is missing the View/Read permission"); errorOccurred = true; continue; } view.checkPermission(View.DELETE); } catch (Exception e) { stderr.println(e.getMessage()); errorOccurred = true; continue; } ViewGroup group = view.getOwner(); if (!group.canDelete(view)) { stderr.format("%s does not allow to delete '%s' view\n", group.getDisplayName(), view.getViewName() ); errorOccurred = true; continue; } group.deleteView(view); } catch (Exception e) { final String errorMsg = String.format("Unexpected exception occurred during deletion of view '%s': %s", view == null ? "(null)" : view.getViewName(), e.getMessage()); stderr.println(errorMsg); LOGGER.warning(errorMsg); errorOccurred = true; continue; } } return errorOccurred ? -1 : 0; }
Source:
public void fillHalfRecords(final ContextAccumulator fullContextAccumulator, final int contextSize) { final String padding = StringUtil.repeatCharNTimes('N', contextSize); for (Map.Entry<String,AlignmentAccumulator[]> fullContext : fullContextAccumulator.artifactMap.entrySet()) { final String context = fullContext.getKey(); final char centralBase = context.charAt(contextSize); final String leadingKey = context.substring(0, contextSize) + centralBase + padding; final String trailingKey = padding + centralBase + context.substring(contextSize + 1, context.length()); final AlignmentAccumulator[] trailingAlignmentAccumulators = this.artifactMap.get(trailingKey); final AlignmentAccumulator[] leadingAlignmentAccumulators = this.artifactMap.get(leadingKey); final AlignmentAccumulator[] fullAlignmentAccumulators = fullContext.getValue(); for (int i=0; i < fullAlignmentAccumulators.length; i++) { trailingAlignmentAccumulators[i].mergeCounts(fullContext.getValue()[i]); leadingAlignmentAccumulators[i].mergeCounts(fullContext.getValue()[i]); } } }

Target:
public void fillHalfRecords(final ContextAccumulator fullContextAccumulator, final int contextSize) { final String padding = StringUtil.repeatCharNTimes('N', contextSize); for (Map.Entry<String,AlignmentAccumulator[]> fullContext : fullContextAccumulator.artifactMap.entrySet()) { final String fullContextKey = fullContext.getKey(); final char centralBase = fullContextKey.charAt(contextSize); final String leadingContextKey = fullContextKey.substring(0, contextSize) + centralBase + padding; final String trailingContextKey = padding + centralBase + fullContextKey.substring(contextSize + 1, fullContextKey.length()); final AlignmentAccumulator[] trailingAlignmentAccumulators = this.artifactMap.get(trailingContextKey); final AlignmentAccumulator[] leadingAlignmentAccumulators = this.artifactMap.get(leadingContextKey); final AlignmentAccumulator[] fullAlignmentAccumulators = fullContext.getValue(); for (int i=0; i < fullAlignmentAccumulators.length; i++) { trailingAlignmentAccumulators[i].merge(fullAlignmentAccumulators[i]); leadingAlignmentAccumulators[i].merge(fullAlignmentAccumulators[i]); } } }
Source:
public static List<CqlIdentifier> wrap( @NonNull Iterable<String> in, @NonNull Function<String, CqlIdentifier> fn) { Preconditions.checkNotNull(in, "Input Iterable must not be null"); Preconditions.checkNotNull(fn, "CqlIdentifier conversion function must not be null"); ImmutableList.Builder<CqlIdentifier> out = ImmutableList.builder(); for (String name : in) { out.add(fn.apply(name)); } return out.build(); }

Target:
private static List<CqlIdentifier> wrap( @NonNull Iterable<String> in, @NonNull Function<String, CqlIdentifier> fn) { Objects.requireNonNull(in, "Input Iterable must not be null"); Objects.requireNonNull(fn, "CqlIdentifier conversion function must not be null"); ImmutableList.Builder<CqlIdentifier> builder = ImmutableList.<CqlIdentifier>builder(); for (String name : in) { builder.add(fn.apply(name)); } return builder.build(); }
Source:
private int getDistanceUntilEdge(Location location, BlockFace face) { Location destLoc = location.clone(); int i; for (i = 0; i < 22; ++i) { destLoc.add(face.getModX(), face.getModY(), face.getModZ()); if (!canBuildThrough(destLoc.getBlock().getType()) || downImmutable(destLoc).getBlock().getType() != Material.OBSIDIAN) { break; } } return destLoc.getBlock().getType() == Material.OBSIDIAN ? i : -1; }

Target:
private int getDistanceUntilEdge(Location location, BlockFace face) { Location destLoc = location.clone(); int distance; for (distance = 0; distance <= MAX_PORTAL_WIDTH_HEIGHT; ++distance) { destLoc.add(face.getModX(), face.getModY(), face.getModZ()); if (!canBuildThrough(destLoc.getBlock().getType()) || downImmutable(destLoc).getBlock().getType() != Material.OBSIDIAN) { break; } } return destLoc.getBlock().getType() == Material.OBSIDIAN ? distance : -1; }
Source:
public void test01_02_requestControllerHandling() { driver.findElement(By.id("requestControllerHandling_01_02")).click(); dbLogProvider.waitForAssertion(); assertThat(driver.getTitle(), is("terasoluna-gfw-functionaltest")); assertThat(dbLogProvider.countContainsMessageAndLevelsAndLogger( "\\[w.xx.0002\\] ResultMessages \\[type=info, list=\\[ResultMessage \\[code=i.gt.me.0004, args=\\[\\], text=null\\]\\]\\]", "INFO", "org.terasoluna.gfw.common.exception.ExceptionLogger"), is(1L)); assertThat(dbLogProvider.countContainsMessageAndLevelsAndLogger( "\\[w.xx.0002\\] ResultMessages \\[type=info, list=\\[ResultMessage \\[code=i.gt.me.0004, args=\\[\\], text=null\\]\\]\\]", "INFO", "org.terasoluna.gfw.common.exception.ExceptionLogger.Monitoring"), is(1L)); assertThat(driver.findElement(By.xpath(" "Info !!")); }

Target:
public void test01_02_requestControllerHandling() { driver.findElement(By.id("requestControllerHandling_01_02")).click(); assertThat(driver.getTitle(), is("terasoluna-gfw-functionaltest")); assertThat(dbLogProvider.countContainsMessageAndLevelsAndLogger( "\\[w.xx.0002\\] ResultMessages \\[type=info, list=\\[ResultMessage \\[code=i.gt.me.0004, args=\\[\\], text=null\\]\\]\\]", "INFO", "org.terasoluna.gfw.common.exception.ExceptionLogger"), is(1L)); assertThat(dbLogProvider.countContainsMessageAndLevelsAndLogger( "\\[w.xx.0002\\] ResultMessages \\[type=info, list=\\[ResultMessage \\[code=i.gt.me.0004, args=\\[\\], text=null\\]\\]\\]", "INFO", "org.terasoluna.gfw.common.exception.ExceptionLogger.Monitoring"), is(1L)); assertThat(driver.findElement(By.xpath(" "Info !!")); }
Source:
public void execute() { String namespace = "<LINK_0>"; String modelName = "typecheck in DT"; GetDMNModelCommand getDMNModelCommand = new GetDMNModelCommand(namespace, modelName); try { getDMNModelCommand.execute(registryContext); fail(); } catch (IllegalStateException ignored) { } registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = getDMNModelCommand.execute(registryContext); assertEquals(namespace, dmnModel.getNamespace()); assertEquals(modelName, dmnModel.getName()); }

Target:
public void execute() { String namespace = "<LINK_0>"; String modelName = "typecheck in DT"; GetDMNModelCommand getDMNModelCommand = new GetDMNModelCommand(namespace, modelName); assertThatThrownBy(() -> getDMNModelCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("There is no DMNRuntime available"); registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = getDMNModelCommand.execute(registryContext); assertEquals(namespace, dmnModel.getNamespace()); assertEquals(modelName, dmnModel.getName()); }
Source:
public boolean executeOnce() { try (Socket ignored = new Socket(host, port)) { return true; } catch (IOException e) { ByteArrayOutputStream out = new ByteArrayOutputStream(); e.printStackTrace(new PrintStream(out)); String str = new String(out.toByteArray()); LOGGER.warn("This is a message from AppIDMan opening the socket didn't work because of: "); LOGGER.warn(str); return false; } }

Target:
public boolean executeOnce() { try (Socket ignored = new Socket(host, port)) { return true; } catch (IOException e) { LOGGER.warn("Socket to host: " + host + " with port: " + String.valueOf(port) + " couldn't be opened", e); return false; } }
Source:
public TouchCalibration getTouchCalibration(int surfaceRotation) { try { return mTouchCalibration[surfaceRotation]; } catch (IllegalArgumentException ex) { Slog.w(InputManagerService.TAG, "Cannot get touch calibration.", ex); return null; } }

Target:
public TouchCalibration getTouchCalibration(int surfaceRotation) { try { return mTouchCalibration[surfaceRotation]; } catch (ArrayIndexOutOfBoundsException ex) { Slog.w(InputManagerService.TAG, "Cannot get touch calibration.", ex); return null; } }
Source:
public void deleteFromRegistry(String resourcePath) { try { registry.delete(resourcePath); log.debug(resourcePath + " Registry Deleted"); } catch (RegistryException e) { log.error(e.getMessage()); } }

Target:
public void deleteFromRegistry(String resourcePath) { try { registry.delete(resourcePath); if ((log.isDebugEnabled())) { log.debug(resourcePath + " Registry Deleted"); } } catch (RegistryException e) { log.error("error while handle with registry", e); } }
Source:
public static void addCodedObs(Patient p, String conceptName, String conceptAnswer, String date) { Obs o = new Obs(); o.setPerson(p); o.setConcept(MohCacheUtils.getConcept(conceptName)); o.setValueCoded(MohCacheUtils.getConcept(conceptAnswer)); o.setObsDatetime(MohTestUtils.makeDate(date)); Obs obs = Context.getObsService().saveObs(o, null); }

Target:
public static void addCodedObs(Patient p, String conceptName, String conceptAnswer, String date) { Obs o = new Obs(); o.setPerson(p); o.setConcept(MohCacheUtils.getConcept(conceptName)); o.setValueCoded(MohCacheUtils.getConcept(conceptAnswer)); o.setObsDatetime(MohTestUtils.makeDate(date)); Context.getObsService().saveObs(o, null); }
Source:
public void put(long ledgerId, long entryId, ByteBuf entry) { lock.readLock().lock(); int entrySize = entry.readableBytes(); int alignedSize = align64(entrySize); try { int offset = currentSegmentOffset.getAndAdd(alignedSize); if (offset + entrySize > segmentSize) { } else { cacheSegments.get(currentSegmentIdx).setBytes(offset, entry, entry.readerIndex(), entry.readableBytes()); cacheIndexes.get(currentSegmentIdx).put(ledgerId, entryId, offset, entrySize); return; } } finally { lock.readLock().unlock(); } lock.writeLock().lock(); try { int offset = currentSegmentOffset.getAndAdd(entrySize); if (offset + entrySize > segmentSize) { currentSegmentIdx = (currentSegmentIdx + 1) % cacheSegments.size(); currentSegmentOffset.set(alignedSize); cacheIndexes.get(currentSegmentIdx).clear(); offset = 0; } cacheSegments.get(currentSegmentIdx).setBytes(offset, entry, entry.readerIndex(), entry.readableBytes()); cacheIndexes.get(currentSegmentIdx).put(ledgerId, entryId, offset, entrySize); } finally { lock.writeLock().unlock(); } }

Target:
public void put(long ledgerId, long entryId, ByteBuf entry) { int entrySize = entry.readableBytes(); int alignedSize = align64(entrySize); lock.readLock().lock(); try { int offset = currentSegmentOffset.getAndAdd(alignedSize); if (offset + entrySize > segmentSize) { } else { cacheSegments.get(currentSegmentIdx).setBytes(offset, entry, entry.readerIndex(), entry.readableBytes()); cacheIndexes.get(currentSegmentIdx).put(ledgerId, entryId, offset, entrySize); return; } } finally { lock.readLock().unlock(); } lock.writeLock().lock(); try { int offset = currentSegmentOffset.getAndAdd(entrySize); if (offset + entrySize > segmentSize) { currentSegmentIdx = (currentSegmentIdx + 1) % cacheSegments.size(); currentSegmentOffset.set(alignedSize); cacheIndexes.get(currentSegmentIdx).clear(); offset = 0; } cacheSegments.get(currentSegmentIdx).setBytes(offset, entry, entry.readerIndex(), entry.readableBytes()); cacheIndexes.get(currentSegmentIdx).put(ledgerId, entryId, offset, entrySize); } finally { lock.writeLock().unlock(); } }
Source:
PermissionNameRenderer(Map<String, String> allFromOutside) { all = new HashMap<String, String>(); all.putAll(allFromOutside); for (Map.Entry<String, String> e : Util.C.permissionNames().entrySet()) { all.put(e.getKey(), e.getValue()); all.put(e.getKey().toLowerCase(), e.getValue()); } }

Target:
PermissionNameRenderer(Map<String, String> allFromOutside) { fromServer = allFromOutside; }
Source:
public void testInputStreamAsynchronousByteChannel() throws Exception { AsynchronousByteChannel abc = mock(AsynchronousByteChannel.class); InputStream is = Channels.newInputStream(abc); Future<Integer> result = mock(Future.class); ArgumentCaptor<ByteBuffer> bbCaptor = ArgumentCaptor.forClass(ByteBuffer.class); final byte[] data = new byte[10]; final int readCount = 5; when(abc.read(bbCaptor.capture())).thenReturn(result); when(result.get()).thenAnswer( new Answer<Integer>() { public Integer answer(InvocationOnMock invocation) { ByteBuffer bb = bbCaptor.getValue(); assertEquals(data.length, bb.remaining()); for (int i = 0;i < readCount;++i) { bb.put((byte)1); } return readCount; } }); assertEquals(readCount, is.read(data)); for (int i = 0;i < data.length;++i) { assertEquals((i < readCount) ? (byte)1 : (byte)0, data[i]); } }

Target:
public void testInputStreamAsynchronousByteChannel() throws Exception { AsynchronousByteChannel abc = mock(AsynchronousByteChannel.class); InputStream is = Channels.newInputStream(abc); Future<Integer> result = mock(Future.class); ArgumentCaptor<ByteBuffer> bbCaptor = ArgumentCaptor.forClass(ByteBuffer.class); final byte[] bytesRead = new byte[10]; when(abc.read(bbCaptor.capture())).thenReturn(result); when(result.get()).thenAnswer( new Answer<Integer>() { public Integer answer(InvocationOnMock invocation) { ByteBuffer bb = bbCaptor.getValue(); assertEquals(bytesRead.length, bb.remaining()); bb.put(new byte[] {0, 1, 2, 3, 4, 5, 6}); return 7; } }); assertEquals(7, is.read(bytesRead)); byte[] bytesExpected = new byte[] { 0, 1, 2, 3, 4, 5, 6, 0, 0, 0 }; assertTrue(Arrays.equals(bytesExpected, bytesRead)); Mockito.verify(abc).read(isA(ByteBuffer.class)); Mockito.verify(result).get(); }
Source:
public void testDownstreamBuildSelector() throws Exception { FreeStyleProject upstream = jenkinsRule.createFreeStyleProject("upstream"); upstream.getBuildersList().add(new FileWriteBuilder("upstream_artifact.txt", "${BUILD_TAG}")); ArtifactArchiver aa = new ArtifactArchiver("upstream_artifact.txt"); aa.setFingerprint(true); upstream.getPublishersList().add(aa); FreeStyleProject copiee = jenkinsRule.createFreeStyleProject("copiee"); CopyArtifact ca = new CopyArtifact("upstream"); ca.setFingerprintArtifacts(true); copiee.getBuildersList().add(ca); copiee.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar")); copiee.getPublishersList().add(new ArtifactArchiver("artifact.txt")); jenkinsRule.assertBuildStatusSuccess(upstream.scheduleBuild2(0)); jenkinsRule.assertBuildStatusSuccess(copiee.scheduleBuild2(0)); WorkflowJob copier = createWorkflow( "copier", "step(copyArtifacts(projectName: 'copiee', selector: downstream(upstreamProjectName: 'upstream', upstreamBuildNumber: '1')));" + "echo readFile('artifact.txt');" ); jenkinsRule.assertLogContains("foobar", jenkinsRule.assertBuildStatusSuccess(copier.scheduleBuild2(0))); }

Target:
public void testDownstreamBuildSelector() throws Exception { FreeStyleProject upstream = jenkinsRule.createFreeStyleProject("upstream"); upstream.getBuildersList().add(new FileWriteBuilder("upstream_artifact.txt", "${BUILD_TAG}")); ArtifactArchiver aa = new ArtifactArchiver("upstream_artifact.txt"); aa.setFingerprint(true); upstream.getPublishersList().add(aa); FreeStyleProject copiee = jenkinsRule.createFreeStyleProject("copiee"); CopyArtifact ca = new CopyArtifact("upstream"); ca.setFingerprintArtifacts(true); copiee.getBuildersList().add(ca); copiee.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar")); copiee.getPublishersList().add(new ArtifactArchiver("artifact.txt")); jenkinsRule.assertBuildStatusSuccess(upstream.scheduleBuild2(0)); jenkinsRule.assertBuildStatusSuccess(copiee.scheduleBuild2(0)); WorkflowJob copier = jenkinsRule.createWorkflow( "copier", "copyArtifacts(projectName: 'copiee', selector: downstream(upstreamProjectName: 'upstream', upstreamBuildNumber: '1'));" + "echo readFile('artifact.txt');" ); jenkinsRule.assertLogContains("foobar", jenkinsRule.assertBuildStatusSuccess(copier.scheduleBuild2(0))); }
Source:
protected T createInstance(Class<? extends T> beanClass) { if (BeanInstanceUtil.hasInjectionConstructor(beanClass)) { try { @SuppressWarnings("unchecked") Constructor<T> cons = (Constructor<T>) BeanInstanceUtil.getInjectionConstructor(beanClass); cons.setAccessible(true); Class<?>[] paramTypes = cons.getParameterTypes(); Object[] params = new Object[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { params[i] = BEANS.get(paramTypes[i]); } return cons.newInstance(params); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new BeanCreationException(beanClass == null ? null : beanClass.getName(), e); } } else { return BeanInstanceUtil.createBean(beanClass); } }

Target:
protected T createInstance(Class<? extends T> beanClass) { @SuppressWarnings("unchecked") Constructor<T> injectCons = (Constructor<T>) BeanInstanceUtil.getInjectionConstructor(beanClass); if (injectCons != null) { try { injectCons.setAccessible(true); return injectCons.newInstance(BeanInstanceUtil.getInjectionArguments(injectCons.getParameterTypes())); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new BeanCreationException(beanClass == null ? null : beanClass.getName(), e); } } else { return BeanInstanceUtil.createBean(beanClass); } }
Source:
protected String sqlxmlToString(SQLXML sqlxml) throws SQLException { String result = sqlxml.getString(); sqlxml.free(); return result; }

Target:
protected String sqlxmlToString(SQLXML sqlxml) throws SQLException { if (sqlxml == null) { return null; } try { String result = sqlxml.getString(); return result; } finally { sqlxml.free(); } }
Source:
public void submitOnPushWithTag() throws GitAPIException, OrmException, IOException, ConfigInvalidException { grant(Permission.SUBMIT, project, "refs/for/refs/heads/master"); grant(Permission.CREATE, project, "refs/tags/*"); PushOneCommit.Result r = pushWithTagTo("refs/for/master%submit"); r.assertOkStatus(); r.assertChange(Change.Status.MERGED, null, admin); assertSubmitApproval(r.getPatchSetId()); assertCommit(project, "refs/heads/master"); assertTag(project, "refs/heads/master", PushOneCommit.TAG); }

Target:
public void submitOnPushWithTag() throws GitAPIException, OrmException, IOException, ConfigInvalidException { grant(Permission.SUBMIT, project, "refs/for/refs/heads/master"); grant(Permission.CREATE, project, "refs/tags/*"); final String tag = "v1.0"; PushOneCommit push = new PushOneCommit(db, admin.getIdent()); push.setTag(tag); PushOneCommit.Result r = push.to(git, "refs/for/master%submit"); r.assertOkStatus(); r.assertChange(Change.Status.MERGED, null, admin); assertSubmitApproval(r.getPatchSetId()); assertCommit(project, "refs/heads/master"); assertTag(project, "refs/heads/master", tag); }
Source:
public DataInputNavigableJsonAdapter(BufferObjectDataInput input, int initialOffset) { this.input = input; this.initialOffset = initialOffset; }

Target:
public DataInputNavigableJsonAdapter(BufferObjectDataInput input, int initialOffset) { this.input = input; this.input.position(initialOffset); this.initialOffset = initialOffset; }
Source:
protected void checkPortRange() { checkArgument((portRangeEnd == null && portRangeStart == null) || (portRangeEnd != null && portRangeStart != null), "Port range must be both present or null"); if (portRangeEnd != null) { checkArgument(protocol == Protocol.TCP || protocol == Protocol.UDP, "Port range can only be set for TCP or UDP"); checkArgument(portRangeEnd > portRangeStart, "portRangeEnd must be greater than portRangeStart"); checkArgument(portRangeEnd >= 1 && portRangeEnd <= 65534, "Port range end must be 1 to 65534"); checkArgument(portRangeStart >= 1 && portRangeStart <= 65534, "Port range start must be 1 to 65534"); } }

Target:
protected void checkPortRange() { checkArgument(!(portRangeEnd == null ^ portRangeStart == null), "Port range must be both present or null"); if (portRangeEnd != null) { checkArgument(protocol == Protocol.TCP || protocol == Protocol.UDP, "Port range can only be set for TCP or UDP"); checkArgument(portRangeEnd > portRangeStart, "portRangeEnd must be greater than portRangeStart"); checkArgument(portRangeEnd >= 1 && portRangeEnd <= 65534, "Port range end must be 1 to 65534"); checkArgument(portRangeStart >= 1 && portRangeStart <= 65534, "Port range start must be 1 to 65534"); } }
Source:
public QueueingOrganisationStore(MessageSender<EntityUpdatedMessage> sender, OrganisationStore delegate) { this.delegate = checkNotNull(delegate); this.sender = checkNotNull(sender); clock = new SystemClock(); entityIdCodec = SubstitutionTableNumberCodec.lowerCaseOnly(); }

Target:
public QueueingOrganisationStore(MessageSender<EntityUpdatedMessage> sender, OrganisationStore delegate) { this(checkNotNull(sender), checkNotNull(delegate), new SystemClock(), SubstitutionTableNumberCodec.lowerCaseOnly()); }
Source:
public MeasurementKey(StudyOutcomeMeasure<? extends Variable> som, Arm a, WhenTaken wt) { if (som.getValue() == null) { throw new NullPointerException("Variable may not be null"); } if (som.getValue() instanceof OutcomeMeasure && a == null) { throw new NullPointerException( "Arm may not be null for Endpoints/ADEs"); } if (wt == null) { throw new NullPointerException("Moment of measurement may not be null"); } d_som = som; d_arm = a; d_wt = wt; }

Target:
public MeasurementKey(StudyOutcomeMeasure<? extends Variable> som, Arm a, WhenTaken wt) { if (som.getValue() instanceof OutcomeMeasure && a == null) throw new NullPointerException("Arm may not be null for Endpoints/ADEs"); if (wt == null) throw new NullPointerException("Moment of measurement may not be null"); d_som = som; d_arm = a; d_wt = wt; }
Source:
public boolean shouldPull(ImageData image) { boolean result = unit.convert(OffsetDateTime.now(ZoneOffset.UTC).toEpochSecond() - image.getCreated(), TimeUnit.SECONDS) > maxAge; if (result) { log.trace("Should pull image with tags: {}", Arrays.asList(image.getRepoTags())); } return result; }

Target:
public boolean shouldPull(ImageData image) { Duration imageAge = Duration.between(image.getCreated(), Instant.now()); boolean result = imageAge.compareTo(maxAge) > 0; if (result) { log.trace("Should pull image with tags: {}", Arrays.asList(image.getRepoTags())); } return result; }
Source:
private void flushUndo(IUndoContext context) { if (DEBUG_OPERATION_HISTORY_DISPOSE) { Tracing.printTrace("OPERATIONHISTORY", "Flushing undo history for " + context); } synchronized (undoRedoHistoryLock) { Object[] filtered = filter(undoList, context); for (Object element : filtered) { IUndoableOperation operation = (IUndoableOperation) element; if (context == GLOBAL_UNDO_CONTEXT || operation.getContexts().length == 1) { undoList.remove(operation); internalRemove(operation); } else { IUndoContext[] contexts = operation.getContexts(); for (IUndoContext context2 : contexts) { if (context2.matches(context)) { operation.removeContext(context2); } } if (operation.getContexts().length == 0) { undoList.remove(operation); internalRemove(operation); } } } } ICompositeOperation endedComposite = null; synchronized (openCompositeLock) { if (openComposite != null) { if (openComposite.hasContext(context)) { if (context == GLOBAL_UNDO_CONTEXT || openComposite.getContexts().length == 1) { endedComposite = openComposite; openComposite = null; } else { openComposite.removeContext(context); } } } } if (endedComposite != null) { notifyNotOK(endedComposite); } }

Target:
private void flushUndo(IUndoContext context) { if (DEBUG_OPERATION_HISTORY_DISPOSE) { Tracing.printTrace("OPERATIONHISTORY", "Flushing undo history for " + context); } synchronized (undoRedoHistoryLock) { Object[] filtered = filter(undoList, context); for (Object element : filtered) { IUndoableOperation operation = (IUndoableOperation) element; if (context == GLOBAL_UNDO_CONTEXT || operation.getContexts().length == 1) { undoList.remove(operation); internalRemove(operation); } else { for (IUndoContext undoContext : operation.getContexts()) { if (undoContext.matches(context)) { operation.removeContext(undoContext); } } if (operation.getContexts().length == 0) { undoList.remove(operation); internalRemove(operation); } } } } ICompositeOperation endedComposite = null; synchronized (openCompositeLock) { if (openComposite != null) { if (openComposite.hasContext(context)) { if (context == GLOBAL_UNDO_CONTEXT || openComposite.getContexts().length == 1) { endedComposite = openComposite; openComposite = null; } else { openComposite.removeContext(context); } } } } if (endedComposite != null) { notifyNotOK(endedComposite); } }
Source:
private Map<String, Object> topicSettings(String prefix) { Map<String, Object> result = originalsWithPrefix(prefix); if (CONFIG_STORAGE_PREFIX.equals(prefix) && result.containsKey(PARTITIONS_SUFFIX)) { log.warn("Ignoring '{}{}={}' setting, since config topic partitions is always 1", prefix, PARTITIONS_SUFFIX, result.get("partitions")); } Object removedPolicy = result.remove("cleanup.policy"); if (removedPolicy != null) { log.warn("Ignoring '{}cleanup.policy={}' setting, since compaction is always used", prefix, removedPolicy); } result.remove(TOPIC_SUFFIX); result.remove(REPLICATION_FACTOR_SUFFIX); result.remove(PARTITIONS_SUFFIX); return result; }

Target:
private Map<String, Object> topicSettings(String prefix) { Map<String, Object> result = originalsWithPrefix(prefix); if (CONFIG_STORAGE_PREFIX.equals(prefix) && result.containsKey(PARTITIONS_SUFFIX)) { log.warn("Ignoring '{}{}={}' setting, since config topic partitions is always 1", prefix, PARTITIONS_SUFFIX, result.get("partitions")); } Object removedPolicy = result.remove(TopicConfig.CLEANUP_POLICY_CONFIG); if (removedPolicy != null) { log.warn("Ignoring '{}cleanup.policy={}' setting, since compaction is always used", prefix, removedPolicy); } result.remove(TOPIC_SUFFIX); result.remove(REPLICATION_FACTOR_SUFFIX); result.remove(PARTITIONS_SUFFIX); return result; }
Source:
protected void mergeBlocks(T stitchedFileMetaData) throws IOException { final Path dst = new Path(filePath, stitchedFileMetaData.getStitchedFileRelativePath()); PathFilter tempFileFilter = new PathFilter() { @Override public boolean accept(Path path) { return path.getName().startsWith(dst.getName()) && path.getName().endsWith(PART_FILE_EXTENTION); } }; if (outputFS.exists(dst.getParent())) { FileStatus[] statuses = outputFS.listStatus(dst.getParent(), tempFileFilter); for (FileStatus status : statuses) { String statusName = status.getPath().getName(); LOG.debug("deleting vagrant file {}", statusName); outputFS.delete(status.getPath(), true); } } tempOutFilePath = new Path(filePath, stitchedFileMetaData.getStitchedFileRelativePath() + '.' + System.currentTimeMillis() + PART_FILE_EXTENTION); try { writeTempOutputFile(stitchedFileMetaData); moveToFinalFile(stitchedFileMetaData); } catch (BlockNotFoundException e) { LOG.info("Block file not found. Assuming recovery mode for file {}. ", e.getBlockPath(), stitchedFileMetaData.getStitchedFileRelativePath()); outputFS.delete(tempOutFilePath, false); } }

Target:
protected void mergeBlocks(T stitchedFileMetaData) throws IOException { final Path dst = new Path(filePath, stitchedFileMetaData.getStitchedFileRelativePath()); PathFilter tempFileFilter = new PathFilter() { @Override public boolean accept(Path path) { return path.getName().startsWith(dst.getName()) && path.getName().endsWith(PART_FILE_EXTENTION); } }; if (outputFS.exists(dst.getParent())) { FileStatus[] statuses = outputFS.listStatus(dst.getParent(), tempFileFilter); for (FileStatus status : statuses) { String statusName = status.getPath().getName(); LOG.debug("deleting vagrant file {}", statusName); outputFS.delete(status.getPath(), true); } } tempOutFilePath = new Path(filePath, stitchedFileMetaData.getStitchedFileRelativePath() + '.' + System.currentTimeMillis() + PART_FILE_EXTENTION); try { writeTempOutputFile(stitchedFileMetaData); moveToFinalFile(stitchedFileMetaData); } catch (BlockNotFoundException e) { LOG.warn("Block file not found. Assuming recovery mode for file {}. ", e.getBlockPath(), stitchedFileMetaData.getStitchedFileRelativePath()); outputFS.delete(tempOutFilePath, false); } }
Source:
protected void onLoadFailure(final Loader loader, final String resultMessage) { showToast(WebsiteErrorMessageMap.get(resultMessage)); }

Target:
protected void onLoadFailure(final Loader loader, final String resultMessage) { String errorKey = resultMessage; if (resultMessage.contains("upvote")) { errorKey = WebsiteErrorMessageMap.ALREADY_UPVOTED; } showToast(WebsiteErrorMessageMap.get(errorKey)); }