auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { Optional<Limiter.Listener> listener = limiter.acquire(exchange); if (!listener.isPresent()) { exchange.getResponse().setStatusCode(HttpStatus.TOO_MANY_REQUESTS); return exchange.getResponse().setComplete(); } return chain.filter(exchange) .doOnSuccess(v -> listener.get().onSuccess()) .doOnError(throwable -> listener.get().onIgnore()); }

Target:
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { return limiter.acquire(exchange) .map(listener -> chain.filter(exchange) .doOnSuccess(v -> listener.onSuccess()) .doOnError(throwable -> listener.onIgnore())) .orElseGet(() -> { exchange.getResponse().setStatusCode(HttpStatus.TOO_MANY_REQUESTS); return exchange.getResponse().setComplete(); }); }
Source:
BiConsumer<ObjectOutput, Object> findWriter(Object obj) { Class<?> clazz = obj.getClass(); AdvancedExternalizer internalExt = internalExts.get(clazz); if (internalExt != null) return (out, object) -> { writeInternalClean(object, internalExt, out); }; AdvancedExternalizer externalExt = externalExts.get(clazz); if (externalExt != null) return (out, object) -> { writeExternalClean(object, externalExt, out); }; return null; }

Target:
BiConsumer<ObjectOutput, Object> findWriter(Object obj) { Class<?> clazz = obj.getClass(); AdvancedExternalizer internalExt = internalExts.get(clazz); if (internalExt != null) return (out, object) -> { writeInternalClean(object, internalExt, out); }; AdvancedExternalizer externalExt = externalExts.get(clazz); if (externalExt != null) return (out, object) -> writeExternalClean(object, externalExt, out); return null; }
Source:
static boolean waitForTcp(final String host, final int port, final int connTimeoutMs, final long overallTimeoutMs) { final long timestamp = System.currentTimeMillis(); final SocketAddress sa = new java.net.InetSocketAddress(host, port); while (System.currentTimeMillis() - timestamp < overallTimeoutMs) { try (final Socket socket = new Socket()) { socket.connect(sa, connTimeoutMs); socket.shutdownInput(); socket.shutdownOutput(); return true; } catch (IOException e) { LOGGER.fine(String.format("waitForTcp: %s:%d", host, port)); } try { Thread.sleep(1000); } catch (InterruptedException e) { LOGGER.fine(String.format("waitForTcp: %s", e.getMessage())); } } return false; }

Target:
static boolean waitForTcp(final String host, final int port, final int connTimeoutMs, final long overallTimeoutMs) { final long timestamp = System.currentTimeMillis(); final SocketAddress sa = new java.net.InetSocketAddress(host, port); while (System.currentTimeMillis() - timestamp < overallTimeoutMs) { try (final Socket socket = new Socket()) { socket.connect(sa, connTimeoutMs); socket.shutdownInput(); socket.shutdownOutput(); return true; } catch (IOException e) { LOGGER.fine(String.format("waitForTcp: %s:%d", host, port)); } try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOGGER.log(Level.FINE, "waitForTcp interrupted.", e); } } return false; }
Source:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBus.getDefault().register(this); segIO.trackScreenView(courseData.getCourse().getName() + " - Handouts"); }

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); segIO.trackScreenView(courseData.getCourse().getName() + " - Handouts"); }
Source:
public void removeMember(PerunSession sess, Group group, Member member) throws InternalErrorException, MemberNotExistsException, NotGroupMemberException, PrivilegeException, GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException { Utils.checkPerunSession(sess); getGroupsManagerBl().checkGroupExists(sess, group); getPerunBl().getMembersManagerBl().checkMemberExists(sess, member); if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, group) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, group)) { throw new PrivilegeException(sess, "removeMember"); } Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME); if (Objects.equals("true", (String) attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) { throw new ExternallyManagedException("Removing of member is not allowed. Group is externally managed."); } getGroupsManagerBl().removeMember(sess, group, member); }

Target:
public void removeMember(PerunSession sess, Group group, Member member) throws InternalErrorException, MemberNotExistsException, NotGroupMemberException, PrivilegeException, GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException { Utils.checkPerunSession(sess); getGroupsManagerBl().checkGroupExists(sess, group); getPerunBl().getMembersManagerBl().checkMemberExists(sess, member); if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, group) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, group)) { throw new PrivilegeException(sess, "removeMember"); } Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME); if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) { throw new ExternallyManagedException("Removing of member is not allowed. Group is externally managed."); } getGroupsManagerBl().removeMember(sess, group, member); }
Source:
private void showAlertDialog() { CustomAlertDialogBuilder stripAlertDialog = new CustomAlertDialogBuilder(getActivity()); stripAlertDialog.setTitle(getResources().getString(R.string.title_alert_strip)). setMessage(R.string.alert_strip).setCancelable(true); stripAlertDialog.setPositiveButton(R.string.strip, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { sendMessageToHandler(MESSAGE_STRIP, null); } }); stripAlertDialog.setNegativeButton(R.string.btn_do_not_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dismiss(); } }); stripAlertDialog.show(); }

Target:
private void showAlertDialog() { CustomAlertDialogBuilder stripAlertDialog = new CustomAlertDialogBuilder(getActivity()); stripAlertDialog.setTitle(R.string.title_alert_strip). setMessage(R.string.alert_strip).setCancelable(true); stripAlertDialog.setPositiveButton(R.string.strip, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { sendMessageToHandler(MESSAGE_STRIP, null); } }); stripAlertDialog.setNegativeButton(R.string.btn_do_not_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dismiss(); } }); stripAlertDialog.show(); }
Source:
protected boolean isDiverseBusiness(PaymentWorksVendor pmwVendor) { if (paymentWorksFormModeService.shouldUseLegacyFormProcessingMode()) { return pmwVendor.isDiverseBusiness(); } else if (paymentWorksFormModeService.shouldUseForeignFormProcessingMode()) { return pmwVendor.isDiverseBusiness() || StringUtils.isNotBlank(pmwVendor.getFederalDivsersityClassifications()) || StringUtils.isNotBlank(pmwVendor.getStateDivsersityClassifications()); } else { throw new IllegalStateException("invalid form mode service"); } }

Target:
protected boolean isDiverseBusiness(PaymentWorksVendor pmwVendor) { if (paymentWorksFormModeService.shouldUseLegacyFormProcessingMode()) { return pmwVendor.isDiverseBusiness(); } else if (paymentWorksFormModeService.shouldUseForeignFormProcessingMode()) { return pmwVendor.isDiverseBusiness() || StringUtils.isNotBlank(pmwVendor.getFederalDiversityClassifications()) || StringUtils.isNotBlank(pmwVendor.getStateDiversityClassifications()); } else { throw new IllegalStateException("invalid form mode service"); } }
Source:
public void sendGetMembersRequest(String cluster_name, Promise promise, boolean returnViewsOnly) throws Exception { clusterName = cluster_name; DiscoveryKey key = new DiscoveryKey(testName, clusterName); Map<Address, Discovery> discoveries = all.get(key); if (discoveries == null) { discoveries = new HashMap<Address, Discovery>(); Map ret = all.putIfAbsent(key, discoveries); if (ret != null) discoveries = ret; } if (log.isTraceEnabled()) log.trace(String.format("Discoveries for %s are : ", key, discoveries)); if (!discoveries.containsKey(local_addr)) { discoveries.put(local_addr, this); if (log.isTraceEnabled()) log.trace(String.format( "Add discovery for %s to cache. The cache now contains: %s", local_addr, discoveries)); } if (discard == null || !discard.isDiscardAll()) { Message msg = createGetMbrsReqMsg(clusterName, returnViewsOnly); if (!discoveries.isEmpty()) { for (Discovery discovery : discoveries.values()) { if (discovery != this) { discovery.up(new Event(Event.MSG, msg)); } } } else { log.debug("No other nodes yet, so skip sending get-members request"); } } else if (discard != null && discard.isDiscardAll()) { log.debug("Not sending discovery because DISCARD is on"); } }

Target:
public void sendGetMembersRequest(String cluster_name, Promise promise, boolean returnViewsOnly) throws Exception { clusterName = cluster_name; DiscoveryKey key = new DiscoveryKey(testName, clusterName); Map<Address, Discovery> discoveries = all.get(key); if (discoveries == null) { discoveries = new HashMap<Address, Discovery>(); Map ret = all.putIfAbsent(key, discoveries); if (ret != null) discoveries = ret; } if (log.isTraceEnabled()) log.trace(String.format("Discoveries for %s are : %s", key, discoveries)); if (!discoveries.containsKey(local_addr)) { discoveries.put(local_addr, this); if (log.isTraceEnabled()) log.trace(String.format( "Add discovery for %s to cache. The cache now contains: %s", local_addr, discoveries)); } if (discard == null || !discard.isDiscardAll()) { Message msg = createGetMbrsReqMsg(clusterName, returnViewsOnly); if (!discoveries.isEmpty()) { for (Discovery discovery : discoveries.values()) { if (discovery != this) { discovery.up(new Event(Event.MSG, msg)); } } } else { log.debug("No other nodes yet, so skip sending get-members request"); } } else if (discard != null && discard.isDiscardAll()) { log.debug("Not sending discovery because DISCARD is on"); } }
Source:
private void startDimmerThread(GroupAddress destination, String item, Command type) { logger.trace("Starting new dimmer thread for item " + item + "."); DimmerThread dimmerThread = new DimmerThread(destination, item, type); itemDimmerThreads.put(item, dimmerThread); dimmerThread.start(); }

Target:
private void startDimmerThread(GroupAddress destination, String item, Command type) { logger.trace("Starting new dimmer thread for item {}.", item); DimmerThread dimmerThread = new DimmerThread(destination, item, type); itemDimmerThreads.put(item, dimmerThread); dimmerThread.start(); }
Source:
private Integer calculateKafkaPartitionCount(final EventTypeStatistics stat) { if (null == stat) { return settings.getDefaultTopicPartitionCount(); } final int maxPartitionsDueParallelism = Math.max(stat.getReadParallelism(), stat.getWriteParallelism()); if (maxPartitionsDueParallelism >= settings.getMaxTopicPartitionCount()) { return settings.getMaxTopicPartitionCount(); } return Math.min(8, Math.max( maxPartitionsDueParallelism, calculatePartitionsAccordingLoad(stat.getExpectedWriteRate(), stat.getMessageSize()))); }

Target:
private Integer calculateKafkaPartitionCount(final EventTypeStatistics stat) { if (null == stat) { return settings.getDefaultTopicPartitionCount(); } final int maxPartitionsDueParallelism = Math.max(stat.getReadParallelism(), stat.getWriteParallelism()); if (maxPartitionsDueParallelism >= settings.getMaxTopicPartitionCount()) { return settings.getMaxTopicPartitionCount(); } return Math.min(settings.getMaxTopicPartitionCount(), Math.max( maxPartitionsDueParallelism, calculatePartitionsAccordingLoad(stat.getMessagesPerMinute(), stat.getMessageSize()))); }
Source:
public int read() throws IOException { if (!open) { throw new ClosedChannelException(); } final MantaObjectInputStream stream = connectOrGetResponse(); final int read = stream.read(); if (read > -1) { position++; } return read; }

Target:
public int read() throws IOException { if (!open) { throw new ClosedChannelException(); } final MantaObjectInputStream stream = connectOrGetResponse(); final int read = stream.read(); if (read > -1) { position.incrementAndGet(); } return read; }
Source:
protected Map<String, List<String>> getRequestParameters(String state) { Map<String, List<String>> params = new HashMap<>(); if (!(state == null || state.isEmpty())) { String decodedState; try { decodedState = URLDecoder.decode(state, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } for (String pair : decodedState.split("&")) { if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } List<String> l = params.get(name); if (l == null) { l = new ArrayList<>(); params.put(name, l); } l.add(value); } } } return params; }

Target:
protected Map<String, List<String>> getRequestParameters(String state) { Map<String, List<String>> params = new HashMap<>(); if (!(state == null || state.isEmpty())) { String decodedState; try { decodedState = URLDecoder.decode(state, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } for (String pair : decodedState.split("&")) { if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } List<String> paramValues = params.get(name); if (paramValues == null) { paramValues = new ArrayList<>(); params.put(name, paramValues); } paramValues.add(value); } } } return params; }
Source:
public void testTemporalCompactionNoCompactionAcrossDays() throws Exception { DateTimeZone localTimeZone = DateTimeZone.forTimeZone(TimeZone.getTimeZone("PST")); long today = Duration.ofNanos(System.nanoTime()).toDays(); long startOfDay1 = localTimeZone.convertLocalToUTC(Duration.ofDays(today).toMillis(), false); long startOfDay2 = localTimeZone.convertLocalToUTC(Duration.ofDays(today + 1).toMillis(), false); long startOfDay3 = localTimeZone.convertLocalToUTC(Duration.ofDays(today + 2).toMillis(), false); List<ShardIndexInfo> inputShards = ImmutableList.of( shardWithTemporalRange(TIMESTAMP, startOfDay1, startOfDay2 - 100), shardWithTemporalRange(TIMESTAMP, startOfDay1, startOfDay1), shardWithTemporalRange(TIMESTAMP, startOfDay2, startOfDay3 - 100), shardWithTemporalRange(TIMESTAMP, startOfDay2, startOfDay2 + 100), shardWithTemporalRange(TIMESTAMP, startOfDay2, startOfDay2), shardWithTemporalRange(TIMESTAMP, startOfDay3, startOfDay3)); Set<OrganizationSet> actual = compactionSetCreator.createCompactionSets(temporalTableInfo, inputShards); assertEquals(actual.size(), 2); Set<OrganizationSet> expected = ImmutableSet.of( new OrganizationSet(temporalTableInfo.getTableId(), extractIndexes(inputShards, 0, 1), OptionalInt.empty()), new OrganizationSet(temporalTableInfo.getTableId(), extractIndexes(inputShards, 2, 3, 4), OptionalInt.empty())); assertEquals(actual, expected); }

Target:
public void testTemporalCompactionNoCompactionAcrossDays() throws Exception { long day1 = Duration.ofDays(Duration.ofNanos(System.nanoTime()).toDays()).toMillis(); long day2 = Duration.ofDays(Duration.ofMillis(day1).toDays() + 1).toMillis(); long day3 = Duration.ofDays(Duration.ofMillis(day1).toDays() + 2).toMillis(); List<ShardIndexInfo> inputShards = ImmutableList.of( shardWithTemporalRange(TIMESTAMP, day1, day1), shardWithTemporalRange(TIMESTAMP, day2, day2), shardWithTemporalRange(TIMESTAMP, day2, day2), shardWithTemporalRange(TIMESTAMP, day1, day1), shardWithTemporalRange(TIMESTAMP, day3, day3)); Set<OrganizationSet> actual = compactionSetCreator.createCompactionSets(temporalTableInfo, inputShards); assertEquals(actual.size(), 2); Set<OrganizationSet> expected = ImmutableSet.of( new OrganizationSet(temporalTableInfo.getTableId(), extractIndexes(inputShards, 0, 3), OptionalInt.empty()), new OrganizationSet(temporalTableInfo.getTableId(), extractIndexes(inputShards, 1, 2), OptionalInt.empty())); assertEquals(actual, expected); }
Source:
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { SQLXML sqlxml = ps.getConnection().createSQLXML(); sqlxml.setString(parameter); ps.setSQLXML(i, sqlxml); sqlxml.free(); }

Target:
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { SQLXML sqlxml = ps.getConnection().createSQLXML(); try { sqlxml.setString(parameter); ps.setSQLXML(i, sqlxml); } finally { sqlxml.free(); } }
Source:
private void createEmptyFolderIgnored() throws Exception { File path = new File(db.getWorkTree(), IGNORED_FOLDER); assertTrue(path.mkdir()); assertTrue(path.isDirectory()); writeTrashFile(GITIGNORE, GITIGNORE + "\n" + IGNORED_FOLDER + "/"); }

Target:
private void createEmptyFolderIgnored() throws Exception { File path = new File(db.getWorkTree(), IGNORED_FOLDER); FileUtils.mkdir(path); writeTrashFile(GITIGNORE, GITIGNORE + "\n" + IGNORED_FOLDER + "/"); }
Source:
public static String extractFilesNameFromUrl(String url) { return url.substring(url.lastIndexOf('/') + 1, url.length()); }

Target:
public static String extractFilesNameFromUrl(String url) throws MalformedURLException { URL urlObject = new URL(url); return urlObject.getPath().replaceAll("/", ""); }
Source:
public ImportCorrection(DataObject correctedObject, CorrectedProperty correctedProperty, String oldValue, String newValue) { super(); Preconditions.checkNotNull(correctedProperty); Preconditions.checkArgument(StringUtils.isNotBlank(oldValue) || StringUtils.isNotBlank(newValue)); this.correctedObject = correctedObject; this.correctedProperty = correctedProperty; this.oldValue = oldValue; this.newValue = newValue; }

Target:
public ImportCorrection(DataObject correctedObject, CorrectedProperty correctedProperty, String oldValue, String newValue) { Preconditions.checkNotNull(correctedProperty); Preconditions.checkArgument(StringUtils.isNotBlank(oldValue) || StringUtils.isNotBlank(newValue)); this.correctedObject = correctedObject; this.correctedProperty = correctedProperty; this.oldValue = oldValue; this.newValue = newValue; }
Source:
private boolean hasSeriesSummary(ProgData progData) { if (progData.getSeason() != null && !Strings.isNullOrEmpty(progData.getSeason().getSeasonSummary())) { return true; } return false; }

Target:
private boolean hasSeriesSummary(ProgData progData) { return (progData.getSeason() != null && !Strings.isNullOrEmpty(progData.getSeason().getSeasonSummary())); }
Source:
public void test_index_initialization() { File java_ucfg_dir = new File(new File(tmp.getRoot(), "ucfg"), "java"); if(java_ucfg_dir.isDirectory()) { for (File file : java_ucfg_dir.listFiles()) { file.delete(); } } CompilationUnitTree cut = getCompilationUnitTreeWithSemantics("class A {String fun() {return \"\";}} "); UCFGJavaVisitor UCFGJavaVisitor = new UCFGJavaVisitor(tmp.getRoot()); UCFGJavaVisitor.fileKey = FILE_KEY; UCFGJavaVisitor.visitCompilationUnit(cut); UCFGJavaVisitor = new UCFGJavaVisitor(tmp.getRoot()); UCFGJavaVisitor.fileKey = FILE_KEY; UCFGJavaVisitor.visitCompilationUnit(cut); String[] list = new File(new File(tmp.getRoot(), "ucfg"), "java").list(); assertThat(list).hasSize(2).containsExactly("ucfg_0.proto", "ucfg_1.proto"); }

Target:
public void test_index_initialization() { File java_ucfg_dir = new File(new File(tmp.getRoot(), "ucfg"), "java"); if(java_ucfg_dir.isDirectory()) { for (File file : java_ucfg_dir.listFiles()) { file.delete(); } } CompilationUnitTree cut = getCompilationUnitTreeWithSemantics("class A {String fun() {return \"\";}} "); UCFGJavaVisitor UCFGJavaVisitor = new UCFGJavaVisitor(tmp.getRoot()); UCFGJavaVisitor.fileKey = FILE_KEY; UCFGJavaVisitor.visitCompilationUnit(cut); UCFGJavaVisitor = new UCFGJavaVisitor(tmp.getRoot()); UCFGJavaVisitor.fileKey = FILE_KEY; UCFGJavaVisitor.visitCompilationUnit(cut); String[] list = java_ucfg_dir.list(); assertThat(list).hasSize(2).containsExactly("ucfg_0.proto", "ucfg_1.proto"); }
Source:
public void flush(final String value) { final int rowIndex = context.getRowIndex(); final int columnIndex = context.getColumnIndex(); String actualValue = (value == null || value.trim().isEmpty()) ? null : value; ((ScenarioGridModel) gridWidget.getModel()).setCellValue(rowIndex, columnIndex, new ScenarioGridCellValue(actualValue)); }

Target:
public void flush(final String value) { final int rowIndex = context.getRowIndex(); final int columnIndex = context.getColumnIndex(); String actualValue = (value == null || value.trim().isEmpty()) ? null : value; gridWidget.getModel().setCellValue(rowIndex, columnIndex, new ScenarioGridCellValue(actualValue, ScenarioSimulationEditorConstants.INSTANCE.insertValue())); }
Source:
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { Dashboard dashboard; response.setContentType(CONTENT_TYPE); response.setCharacterEncoding(ENCODING); try { if (FakeDataGenerator.headerWantsFakeData(request)) { dashboard = getFakeDashboard(); } else if ("nocache".equals(request.getHeader("Prefer"))) { dashboard = getDashboard(); dashboard.setInventory(lookupInventory()); } else { dashboard = getDashboardFromCache(); } ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(response.getOutputStream(), dashboard); } catch (final DashboardDataException se) { log.error("Unable to retrieve dashboard data", se); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(response.getOutputStream(), new DashboardError("Unable to retrieve dashboard data")); } }

Target:
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { Dashboard dashboard; response.setContentType(CONTENT_TYPE); response.setCharacterEncoding(ENCODING); try { boolean preferFake = false; boolean preferError = false; boolean preferNoCache = false; String preferHeader = request.getHeader(PREFER_HEADER); String[] preferOptions = preferHeader == null ? new String[0] : preferHeader.trim().split("\\s*,\\s*"); for (String option : preferOptions) { switch (option) { case PREFER_FAKE_DATA: preferFake = true; break; case PREFER_ERROR: preferError = true; break; case PREFER_NO_CACHE: preferNoCache = true; break; } } if (preferError) { log.debug("client requested an error condition"); throw new ServletException("An error condition was requested."); } else if (preferFake) { log.debug("client requested fake data"); dashboard = getFakeDashboard(); } else if (preferNoCache) { log.debug("client requested non-cache direct query data"); dashboard = getDashboard(); dashboard.setInventory(lookupInventory()); } else { dashboard = getDashboardFromCache(); } ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(response.getOutputStream(), dashboard); } catch (final DashboardDataException se) { log.error("Unable to retrieve dashboard data", se); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(response.getOutputStream(), new DashboardError("Unable to retrieve dashboard data")); } }
Source:
private void addApplicationAttributes(Connection conn, Map<String, String> attributes, int applicationId, int tenantId) throws APIManagementException { PreparedStatement ps = null; ResultSet rs = null; try { if (attributes != null) { ps = conn.prepareStatement(SQLConstants.ADD_APPLICATION_ATTRIBUTES_SQL); for (String key : attributes.keySet()) { if (!StringUtils.isEmpty(key) && !StringUtils.isEmpty(attributes.get(key))) { ps.setInt(1, applicationId); ps.setString(2, key); ps.setString(3, attributes.get(key)); ps.setInt(4, tenantId); ps.addBatch(); } } int[] update = ps.executeBatch(); } } catch (SQLException e) { handleException("Error in adding attributes of application with id: " + applicationId , e); } finally { APIMgtDBUtil.closeAllConnections(ps, null, rs); } }

Target:
private void addApplicationAttributes(Connection conn, Map<String, String> attributes, int applicationId, int tenantId) throws APIManagementException { PreparedStatement ps = null; ResultSet rs = null; try { if (attributes != null) { ps = conn.prepareStatement(SQLConstants.ADD_APPLICATION_ATTRIBUTES_SQL); for (Map.Entry<String, String> attribute : attributes.entrySet()) { if (StringUtils.isNotEmpty(attribute.getKey()) && StringUtils.isNotEmpty(attribute.getValue())) { ps.setInt(1, applicationId); ps.setString(2, attribute.getKey()); ps.setString(3, attribute.getValue()); ps.setInt(4, tenantId); ps.addBatch(); } } int[] update = ps.executeBatch(); } } catch (SQLException e) { handleException("Error in adding attributes of application with id: " + applicationId , e); } finally { APIMgtDBUtil.closeAllConnections(ps, null, rs); } }
Source:
private void verifyRunListForEnvironment(Map<String, List<String>> envRunList, String envName, String... expectedEntries) { assertTrue(envRunList.containsKey(envName), "envRunList contains " + envName); assertEquals(envRunList.get(envName).size(), expectedEntries.length, "envRunList size for '" + envName); assertTrue(envRunList.get(envName).containsAll(Arrays.asList(expectedEntries)), "envRunList for e1 contains " + Arrays.asList(expectedEntries)); }

Target:
public static void verifyRunListForEnvironment(Map<String, List<String>> envRunList, String envName, String... expectedEntries) { assertTrue(envRunList.containsKey(envName), "envRunList contains " + envName); assertEquals(envRunList.get(envName).size(), expectedEntries.length, "envRunList size for '" + envName); assertTrue(envRunList.get(envName).containsAll(Arrays.asList(expectedEntries)), "envRunList for e1 contains " + Arrays.asList(expectedEntries)); }
Source:
public CliCommand init(final Arguments args) throws Exception { this.filterParams = args.getFilterParams(); this.bucketName = args.getBucket(); if (!Guard.isStringNullOrEmpty(args.getPrefix())) { throw new BadArgumentException("'-p' prefix is not supported."); } this.prefix = null; return this; }

Target:
public CliCommand init(final Arguments args) throws Exception { this.filterParams = args.getFilterParams(); this.bucketName = args.getBucket(); if (!Guard.isStringNullOrEmpty(args.getPrefix())) { LOG.warn("'-p' prefix is not supported."); } this.prefix = null; return this; }
Source:
protected void doWork(IProgressMonitor monitor) throws OseeCoreException { if (workPackages.isEmpty()) { throw new OseeArgumentException("ERROR", "Must provide Work Packages"); } for (IAtsWorkPackage workPkg : workPackages) { for (Artifact art : ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.WorkPackageGuid, workPkg.getGuid(), AtsUtilCore.getAtsBranchToken(), QueryOptions.EXACT_MATCH_OPTIONS)) { AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) art; EarnedValueReportResult result = new EarnedValueReportResult(workPkg, art); results.add(result); result.setValue(Work_Package_Id, workPkg.getWorkPackageId()); result.setValue(Work_Package_Name, workPkg.getName()); result.setValue(Work_Package_Percent, String.valueOf(workPkg.getWorkPackagePercent())); result.setValue(Work_Package_Guid, String.valueOf(workPkg.getGuid())); result.setValue(Related_Action_Id, getActionId(art)); result.setValue(Related_Action_Name, art.getName()); result.setValue(Related_Action_Type, awa.getParentTeamWorkflow().getTeamDefinition().getName()); result.setValue(Related_Action_Percent, String.valueOf(PercentCompleteTotalUtil.getPercentCompleteTotal(art))); result.setValue(Related_Action_Guid, art.getGuid()); } } }

Target:
protected void doWork(IProgressMonitor monitor) throws OseeCoreException { if (workPackages.isEmpty()) { throw new OseeArgumentException("ERROR", "Must provide Work Packages"); } for (IAtsWorkPackage workPkg : workPackages) { checkForCancelledStatus(monitor); for (Artifact art : ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.WorkPackageGuid, workPkg.getGuid(), AtsUtilCore.getAtsBranchToken(), QueryOptions.EXACT_MATCH_OPTIONS)) { checkForCancelledStatus(monitor); AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) art; EarnedValueReportResult result = new EarnedValueReportResult(workPkg, art); results.add(result); result.setValue(Work_Package_Id, workPkg.getWorkPackageId()); result.setValue(Work_Package_Name, workPkg.getName()); result.setValue(Work_Package_Percent, String.valueOf(workPkg.getWorkPackagePercent())); result.setValue(Work_Package_Guid, String.valueOf(workPkg.getGuid())); result.setValue(Related_Action_Id, getActionId(art)); result.setValue(Related_Action_Name, art.getName()); result.setValue(Related_Action_Type, awa.getParentTeamWorkflow().getTeamDefinition().getName()); result.setValue(Related_Action_Percent, String.valueOf(PercentCompleteTotalUtil.getPercentCompleteTotal(art))); result.setValue(Related_Action_Guid, art.getGuid()); } } }
Source:
public LockResponseV2 lock(LockRequestV2 request) { LockResponseV2 delegateResponse = delegate.lock(request); if (delegateResponse.wasSuccessful()) { return ImmutableLockResponseV2.builder() .from(delegateResponse) .tokenOrEmpty(makeSerializable(delegateResponse.getToken())) .build(); } return ImmutableLockResponseV2.copyOf(delegateResponse); }

Target:
public LockResponseV2 lock(LockRequestV2 request) { LockResponseV2 delegateResponse = delegate.lock(request); if (delegateResponse.wasSuccessful()) { return ImmutableLockResponseV2.builder() .from(delegateResponse) .tokenOrEmpty(makeSerializable(delegateResponse.getToken())) .build(); } return delegateResponse; }
Source:
public KnoxShellTable greaterThanOrEqualTo(Comparable<? extends Object> comparable) throws KnoxShellTableFilterException { return filter(s -> s.compareTo(comparable) > 0 || s.compareTo(comparable) == 0); }

Target:
public KnoxShellTable greaterThanOrEqualTo(Comparable<? extends Object> comparable) throws KnoxShellTableFilterException { return filter(s -> s.compareTo(comparable) > 0 || s.equals(comparable)); }
Source:
private String buildMessageForCompositeId(Long clusterId, Long serviceId) { return String.format("cluster id <%d>, id <%d>", clusterId, serviceId); }

Target:
private String buildMessageForCompositeId(Long clusterId, Long serviceId) { return String.format("cluster id <%d>, service id <%d>", clusterId, serviceId); }
Source:
public void testJavaDocsRecognition() throws Exception { final List<BlockCommentPositionTestMetadata> metadataList = Arrays.asList( new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnClass.java", BlockCommentPosition::isOnClass, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnMethod.java", BlockCommentPosition::isOnMethod, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnField.java", BlockCommentPosition::isOnField, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnEnum.java", BlockCommentPosition::isOnEnum, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnConstructor.java", BlockCommentPosition::isOnConstructor, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnInterface.java", BlockCommentPosition::isOnInterface, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnAnnotation.java", BlockCommentPosition::isOnAnnotationDef, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnEnumMember.java", BlockCommentPosition::isOnEnumConstant, 2) ); for (BlockCommentPositionTestMetadata metadata : metadataList) { final DetailAST ast = TestUtils.parseFile( new File(getPath(metadata.getFileName())) ); final int matches = foundJavaDocsCount(ast, metadata.getAssertion()); assertEquals(metadata.getMatchesNum(), matches); } }

Target:
public void testJavaDocsRecognition() throws Exception { final List<BlockCommentPositionTestMetadata> metadataList = Arrays.asList( new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnClass.java", BlockCommentPosition::isOnClass, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnMethod.java", BlockCommentPosition::isOnMethod, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnField.java", BlockCommentPosition::isOnField, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnEnum.java", BlockCommentPosition::isOnEnum, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnConstructor.java", BlockCommentPosition::isOnConstructor, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnInterface.java", BlockCommentPosition::isOnInterface, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnAnnotation.java", BlockCommentPosition::isOnAnnotationDef, 3), new BlockCommentPositionTestMetadata("InputBlockCommentPositionOnEnumMember.java", BlockCommentPosition::isOnEnumConstant, 2) ); for (BlockCommentPositionTestMetadata metadata : metadataList) { final DetailAST ast = TestUtils.parseFile( new File(getPath(metadata.getFileName())) ); final int matches = getJavadocsCount(ast, metadata.getAssertion()); assertEquals(metadata.getMatchesNum(), matches); } }
Source:
public void Rollback() { log.errorFormat("Transaction rolled-back for command: {0}.", CommandBase.this.getClass().getName()); try { if (this instanceof Quotable) { ((Quotable) this).rollbackQuota(); } } catch (Exception e) { log.debug("RollbackQuota: failed (may be because quota is disabled)", e); } cancelTasks(); }

Target:
public void Rollback() { log.errorFormat("Transaction rolled-back for command: {0}.", CommandBase.this.getClass().getName()); try { if (this instanceof Quotable) { ((Quotable) this).rollbackQuota(); } } catch (NullPointerException e) { log.debug("RollbackQuota: failed (may be because quota is disabled)", e); } cancelTasks(); }
Source:
public static SQLDatabase openSqlDatabase(String dbFilename, KeyProvider provider) throws IOException { boolean runningOnAndroid = Misc.isRunningOnAndroid(); boolean useSqlCipher = (provider.getEncryptionKey() != null); makeSureFileExists(dbFilename); try { if (runningOnAndroid) { if (useSqlCipher) { return (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.android.AndroidSQLCipherSQLite") .getMethod("openAndroidSQLite", String.class, KeyProvider.class) .invoke(null, new Object[]{dbFilename, provider}); } else { return (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.android.AndroidSQLite") .getMethod("createAndroidSQLite", String.class) .invoke(null, dbFilename); } } else { if (useSqlCipher) { throw new IOException("No SQLCipher-based database implementation for Java SE"); } else { return (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.sqlite4java.SQLiteWrapper") .getMethod("openSQLiteWrapper", String.class) .invoke(null, dbFilename); } } } catch (Exception e) { logger.log(Level.SEVERE, "Failed to load database module", e); return null; } }

Target:
public static SQLDatabase openSqlDatabase(String dbFilename, KeyProvider provider) throws IOException { boolean runningOnAndroid = Misc.isRunningOnAndroid(); boolean useSqlCipher = (provider.getEncryptionKey() != null); makeSureFileExists(dbFilename); try { if (runningOnAndroid) { if (useSqlCipher) { SQLDatabase result = (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.android.AndroidSQLCipherSQLite") .getMethod("openAndroidSQLite", String.class, KeyProvider.class) .invoke(null, new Object[]{dbFilename, provider}); if (validateOpenedDatabase(result)) { return result; } else { return null; } } else { return (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.android.AndroidSQLite") .getMethod("createAndroidSQLite", String.class) .invoke(null, dbFilename); } } else { if (useSqlCipher) { throw new UnsupportedOperationException("No SQLCipher-based database implementation for Java SE"); } else { return (SQLDatabase) Class.forName("com.cloudant.sync.sqlite.sqlite4java.SQLiteWrapper") .getMethod("openSQLiteWrapper", String.class) .invoke(null, dbFilename); } } } catch (Exception e) { logger.log(Level.SEVERE, "Failed to load database module", e); return null; } }
Source:
protected void onCancelled() { Logger.d(TAG, "HttpWebRequest onCancelled thread" + android.os.Process.myTid()); if (null != mCallback) { mCallback.onComplete(null, new AuthenticationCancelError()); } }

Target:
protected void onCancelled() { Logger.d(TAG, "HttpWebRequest onCancelled thread:" + android.os.Process.myTid()); if (null != mCallback) { mCallback.onComplete(null, new AuthenticationCancelError()); } }
Source:
public void testWaitForPortFreeWhenAbortingOnTimeout() throws Exception { ServerSocket serverSocket = openServerSocket(); try { int port = serverSocket.getLocalPort(); String cmd = BashCommands.waitForPortFree(port, Duration.ONE_SECOND, true); int exitcode = loc.execCommands("test", ImmutableList.of(cmd)); assertEquals(exitcode, 1); serverSocket.close(); assertTrue(Networking.isPortAvailable(port)); String cmd2 = BashCommands.waitForPortFree(port, Duration.ONE_SECOND, true); int exitcode2 = loc.execCommands("test", ImmutableList.of(cmd2)); assertEquals(exitcode2, 0); } finally { serverSocket.close(); } }

Target:
public void testWaitForPortFreeWhenAbortingOnTimeout() throws Exception { ServerSocket serverSocket = openServerSocket(); try { int port = serverSocket.getLocalPort(); String cmd = BashCommands.waitForPortFree(port, Duration.ONE_SECOND, true); int exitcode = loc.execCommands("test", ImmutableList.of(cmd)); assertEquals(exitcode, 1); serverSocket.close(); assertTrue(Networking.isPortAvailable(port)); int exitcode2 = loc.execCommands("test", ImmutableList.of(cmd)); assertEquals(exitcode2, 0); } finally { serverSocket.close(); } }
Source:
private static Class lookupKeyGenClass() { final Class keyGenClass; if (ClassUtil.checkForClass(KEYGEN_CLASS_JDK8_SUN)) { keyGenClass = ClassUtil.classForName(KEYGEN_CLASS_JDK8_SUN); } else if (ClassUtil.checkForClass(KEYGEN_CLASS_JDK7_SUN)) { keyGenClass = ClassUtil.classForName(KEYGEN_CLASS_JDK7_SUN); } else if (ClassUtil.checkForClass(KEYGEN_CLASS_JDK8_IBM)) { keyGenClass = ClassUtil.classForName(KEYGEN_CLASS_JDK8_IBM); } else if (ClassUtil.checkForClass(KEYGEN_CLASS_JDK7_IBM)) { keyGenClass = ClassUtil.classForName(KEYGEN_CLASS_JDK7_IBM); } else { throw new IllegalStateException( "Cannot find any key-generator class: Tried Sun Java 8's " + KEYGEN_CLASS_JDK8_SUN + ", Sun Java 7's " + KEYGEN_CLASS_JDK7_SUN + ", IBM Java 8's " + KEYGEN_CLASS_JDK8_IBM + " and IBM Java 7's " + KEYGEN_CLASS_JDK7_IBM); } return keyGenClass; }

Target:
private static Class lookupKeyGenClass() { Class keyGenClass = null; for (final String keyGenCandidate : new String[]{ KEYGEN_CLASS_JDK8_SUN, KEYGEN_CLASS_JDK7_SUN, KEYGEN_CLASS_JDK8_IBM, KEYGEN_CLASS_JDK7_IBM }) { keyGenClass = ClassUtil.classForName(keyGenCandidate); if (keyGenClass != null) { break; } } if (keyGenClass == null) { throw new IllegalStateException( "Cannot find any key-generator class: Tried Sun Java 8's " + KEYGEN_CLASS_JDK8_SUN + ", Sun Java 7's " + KEYGEN_CLASS_JDK7_SUN + ", IBM Java 8's " + KEYGEN_CLASS_JDK8_IBM + " and IBM Java 7's " + KEYGEN_CLASS_JDK7_IBM); } return keyGenClass; }
Source:
private void setHeaderTextAndscroll(MotionEvent event){ if (mListView == null) { return; } String headerString = sections[sectionForPoint(event.getY())]; header.setText(headerString); ListAdapter adapter = mListView.getAdapter(); if(sectionIndexer == null){ if(adapter instanceof HeaderViewListAdapter){ sectionIndexer = (SectionIndexer) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); }else if(adapter instanceof SectionIndexer){ sectionIndexer = (SectionIndexer)adapter; }else{ throw new RuntimeException("listview sets adapter does not implement SectionIndexer interface"); } } String[] adapterSections = (String[]) sectionIndexer.getSections(); try { for (int i = adapterSections.length - 1; i > -1; i--) { if(adapterSections[i].equals(headerString)){ mListView.setSelection(sectionIndexer.getPositionForSection(i)); break; } } } catch (Exception e) { Log.e("setHeaderTextAndScroll", e.getMessage()); } }

Target:
private void setHeaderTextAndscroll(MotionEvent event){ if (mListView == null) { return; } String headerString = sections[sectionForPoint(event.getY())]; header.setText(headerString); ListAdapter adapter = mListView.getAdapter(); if(sectionIndex == null){ if(adapter instanceof HeaderViewListAdapter){ sectionIndex = (SectionIndexer) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); }else if(adapter instanceof SectionIndexer){ sectionIndex = (SectionIndexer)adapter; }else{ throw new RuntimeException("listview sets adapter does not implement SectionIndexer interface"); } } String[] adapterSections = (String[]) sectionIndex.getSections(); try { for (int i = adapterSections.length - 1; i > -1; i--) { if(adapterSections[i].equals(headerString)){ mListView.setSelection(sectionIndex.getPositionForSection(i)); break; } } } catch (Exception e) { Log.e("setHeaderTextAndScroll", e.getMessage()); } }
Source:
void load(String file) throws IOException { try (InputStream inputStream = new FileInputStream(file)) { properties.loadFromXML(inputStream); } String defaultConfigFile = properties.getProperty("config.default"); if (defaultConfigFile != null) { try (InputStream inputStream = new FileInputStream(defaultConfigFile)) { Properties defaultProperties = new Properties(); defaultProperties.loadFromXML(inputStream); Enumeration props = defaultProperties.propertyNames(); while (props.hasMoreElements()) { String key = (String) props.nextElement(); if (!properties.containsKey(key)) { properties.setProperty(key, defaultProperties.getProperty(key)); } } } } }

Target:
void load(String file) throws IOException { String defaultConfigFile = properties.getProperty("config.default"); if (defaultConfigFile != null) { try (InputStream inputStream = new FileInputStream(defaultConfigFile)) { properties.loadFromXML(inputStream); } } try (InputStream inputStream = new FileInputStream(file)) { Properties props = new Properties(); props.loadFromXML(inputStream); properties.putAll(props); } if ("true".equals(System.getenv("CONFIG_USE_ENV"))) { useEnvVars = true; } else { useEnvVars = properties.getProperty("config.useEnv", "false").equalsIgnoreCase("true"); } }
Source:
public static int hexDigitMsb0ToInt(final char hexDigit) { switch (hexDigit) { case '0': return 0x0; case '1': return 0x8; case '2': return 0x4; case '3': return 0xC; case '4': return 0x2; case '5': return 0xA; case '6': return 0x6; case '7': return 0xE; case '8': return 0x1; case '9': return 0x9; case 'a':// fall through case 'A': return 0x5; case 'b':// fall through case 'B': return 0xD; case 'c':// fall through case 'C': return 0x3; case 'd':// fall through case 'D': return 0xB; case 'e':// fall through case 'E': return 0x7; case 'f':// fall through case 'F': return 0xF; default: throw IllegalArgumentExceptions.format("Cannot interpret '%s' as a hexadecimal digit", hexDigit); } }

Target:
public static int hexDigitMsb0ToInt(final char hexDigit) { switch (hexDigit) { case '0': return 0x0; case '1': return 0x8; case '2': return 0x4; case '3': return 0xC; case '4': return 0x2; case '5': return 0xA; case '6': return 0x6; case '7': return 0xE; case '8': return 0x1; case '9': return 0x9; case 'a':// fall through case 'A': return 0x5; case 'b':// fall through case 'B': return 0xD; case 'c':// fall through case 'C': return 0x3; case 'd':// fall through case 'D': return 0xB; case 'e':// fall through case 'E': return 0x7; case 'f':// fall through case 'F': return 0xF; default: throw IllegalArgumentExceptions.format("Cannot interpret '%d' as a hexadecimal digit", hexDigit); } }
Source:
private void printContainerLog(String containerId) { LogCallback loggingCallback = new LogCallback(); dockerClient.logContainerCmd(containerId) .withStdErr(true) .withStdOut(true) .withFollowStream(true) .withTailAll() .exec(loggingCallback); try { loggingCallback.awaitCompletion(3, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } log.infof("Container log:\n%s", loggingCallback.toString()); }

Target:
private void printContainerLog(String containerId) { LogCallback loggingCallback = new LogCallback(); dockerClient.logContainerCmd(containerId) .withStdErr(true) .withStdOut(true) .withFollowStream(true) .withTailAll() .exec(loggingCallback); try { loggingCallback.awaitCompletion(3, TimeUnit.SECONDS); } catch (InterruptedException e) { log.error(e.getMessage()); Thread.currentThread().interrupt(); } }
Source:
public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) { $(selectToEnhance).as(Chosen.Chosen).chosen(); } }

Target:
public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) { ChosenOptions options = new ChosenOptions().setResources(pageProductChosenResources); $(selectToEnhance).as(Chosen.Chosen).chosen(options); } }
Source:
protected void applyInformationWithProgress() { final Runnable runnable = new GoImportOptimizer().processFile(myFile); DocumentUtil.writeInRunUndoTransparentAction(runnable); }

Target:
protected void applyInformationWithProgress() { final Project project = myFile.getProject(); UndoManager undoManager = UndoManager.getInstance(project); if (undoManager.isUndoInProgress() || undoManager.isRedoInProgress()) return; DocumentUtil.writeInRunUndoTransparentAction(myRunnableFix); }
Source:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor actMonitor) throws CoreException { String taskName; if (branches.size() == 1) taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, branches .iterator().next().getName()); else { StringBuffer names = new StringBuffer(); for (Ref ref : branches) names.append(ref.getName()).append(", "); taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, names.substring(0, names.length() - 2)); } actMonitor.beginTask(taskName, branches.size()); for (Ref branch : branches) { try { new Git(repository).branchDelete().setBranchNames( branch.getName()).setForce(force).call(); status = OK; } catch (NotMergedException e) { status = REJECTED_UNMERGED; break; } catch (CannotDeleteCurrentBranchException e) { status = REJECTED_CURRENT; break; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } actMonitor.worked(1); } actMonitor.done(); } }; ResourcesPlugin.getWorkspace().run(action, monitor); }

Target:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor actMonitor) throws CoreException { String taskName; if (branches.size() == 1) taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, branches .iterator().next().getName()); else { StringBuilder names = new StringBuilder(); for (Iterator<Ref> it = branches.iterator(); it.hasNext(); ) { Ref ref = it.next(); names.append(ref.getName()); if (it.hasNext()) names.append(", "); } taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, names.substring(0, names.length() - 2)); } actMonitor.beginTask(taskName, branches.size()); for (Ref branch : branches) { try { new Git(repository).branchDelete().setBranchNames( branch.getName()).setForce(force).call(); status = OK; } catch (NotMergedException e) { status = REJECTED_UNMERGED; break; } catch (CannotDeleteCurrentBranchException e) { status = REJECTED_CURRENT; break; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } actMonitor.worked(1); } actMonitor.done(); } }; ResourcesPlugin.getWorkspace().run(action, monitor); }
Source:
public void move(final String webInterceptorName, int index){ final int currentIndex = this.indexOf(webInterceptorName); if (-1 != currentIndex) { WebInterceptor webInterceptorRemoved = this.interceptors.remove(currentIndex); this.add(index, webInterceptorRemoved); } }

Target:
public void move(final String webInterceptorName, int index){ if (index >= 0 && index <= this.interceptors.size()) { final int currentIndex = this.indexOf(webInterceptorName); if (-1 != currentIndex) { WebInterceptor webInterceptorRemoved = this.interceptors.remove(currentIndex); this.add(index, webInterceptorRemoved); } }else{ throw new IndexOutOfBoundsException(); } }