auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setData(IComponent component){ if ( !(component instanceof ICourse ) ) return; this.rootComponent = component; mData.clear(); this.sections = new SectionRow[0]; if ( rootComponent != null ) { ICourse course = (ICourse)rootComponent; int sectionsNumber = course.getChapters().size(); sections = new SectionRow[sectionsNumber]; int sectionPosition = 0, listPosition = 0; for (char i=0; i<sectionsNumber; i++) { IChapter chapter = course.getChapters().get(i); SectionRow section = new SectionRow(SectionRow.SECTION, chapter ); section.sectionPosition = sectionPosition; section.listPosition = listPosition++; sections[sectionPosition] = section; mData.add(section); List<ISequential> sequentials = chapter.getSequential(); for (int j=0;j<sequentials.size();j++) { SectionRow item = new SectionRow(SectionRow.ITEM, sequentials.get(j) ); item.sectionPosition = sectionPosition; item.listPosition = listPosition++; mData.add(item); } sectionPosition++; } } notifyDataSetChanged(); }

Target:
public void setData(IComponent component){ if ( !(component instanceof ICourse ) ) return; this.rootComponent = component; mData.clear(); this.sections = new SectionRow[0]; if ( rootComponent != null ) { ICourse course = (ICourse)rootComponent; int sectionsNumber = course.getChapters().size(); sections = new SectionRow[sectionsNumber]; int sectionPosition = 0, listPosition = 0; for (int i=0; i<sectionsNumber; i++) { IChapter chapter = course.getChapters().get(i); SectionRow section = new SectionRow(SectionRow.SECTION, chapter ); section.sectionPosition = sectionPosition; section.listPosition = listPosition++; sections[sectionPosition] = section; mData.add(section); List<ISequential> sequentials = chapter.getSequential(); for (int j=0;j<sequentials.size();j++) { SectionRow item = new SectionRow(SectionRow.ITEM, sequentials.get(j) ); item.sectionPosition = sectionPosition; item.listPosition = listPosition++; mData.add(item); } sectionPosition++; } } notifyDataSetChanged(); }
Source:
private static void makeRequest(final String url, final String method, final JSONObject jsonBody, final ResponseHandler responseHandler, final int timeout, final String cacheKey) { if (method != null && OneSignal.shouldLogUserPrivacyConsentErrorMessageForMethodName(null)) return; if (OSUtils.isThreadRunningOnMainThread()) throw new OneSignalNetworkCallException("Method: " + method + " was called from the Main Thread!"); final Thread[] callbackThread = new Thread[1]; Thread connectionThread = new Thread(new Runnable() { public void run() { callbackThread[0] = startHTTPConnection(url, method, jsonBody, responseHandler, timeout, cacheKey); } }, "OS_HTTPConnection"); connectionThread.start(); try { connectionThread.join(getThreadTimeout(timeout)); if (connectionThread.getState() != Thread.State.TERMINATED) connectionThread.interrupt(); if (callbackThread[0] != null) callbackThread[0].join(); } catch (InterruptedException e) { e.printStackTrace(); } }

Target:
private static void makeRequest(final String url, final String method, final JSONObject jsonBody, final ResponseHandler responseHandler, final int timeout, final String cacheKey) { if (OSUtils.isRunningOnMainThread()) throw new OneSignalNetworkCallException("Method: " + method + " was called from the Main Thread!"); if (method != null && OneSignal.shouldLogUserPrivacyConsentErrorMessageForMethodName(null)) return; final Thread[] callbackThread = new Thread[1]; Thread connectionThread = new Thread(new Runnable() { public void run() { callbackThread[0] = startHTTPConnection(url, method, jsonBody, responseHandler, timeout, cacheKey); } }, "OS_HTTPConnection"); connectionThread.start(); try { connectionThread.join(getThreadTimeout(timeout)); if (connectionThread.getState() != Thread.State.TERMINATED) connectionThread.interrupt(); if (callbackThread[0] != null) callbackThread[0].join(); } catch (InterruptedException e) { e.printStackTrace(); } }
Source:
public int hashCode() { int result = getHostname().hashCode(); result = 31 * result + getPort(); result = 31 * result + getBatchSize(); result = 31 * result + getFlushPeriod().hashCode(); result = 31 * result + getMaxQueueSize().hashCode(); result = 31 * result + getDruidToGraphiteEventConverter().hashCode(); result = 31 * result + (getAlertEmitters() != null ? getAlertEmitters().hashCode() : 0); result = 31 * result + (getRequestLogEmitters() != null ? getRequestLogEmitters().hashCode() : 0); result = 31 * result + getEmitWaitTime().hashCode(); result = 31 * result + getWaitForEventTime().hashCode(); return result; }

Target:
public int hashCode() { int result = getHostname().hashCode(); result = 31 * result + getPort(); result = 31 * result + getBatchSize(); result = 31 * result + getProtocol().hashCode(); result = 31 * result + getFlushPeriod().hashCode(); result = 31 * result + getMaxQueueSize().hashCode(); result = 31 * result + getDruidToGraphiteEventConverter().hashCode(); result = 31 * result + (getAlertEmitters() != null ? getAlertEmitters().hashCode() : 0); result = 31 * result + (getRequestLogEmitters() != null ? getRequestLogEmitters().hashCode() : 0); result = 31 * result + getEmitWaitTime().hashCode(); result = 31 * result + getWaitForEventTime().hashCode(); return result; }
Source:
public ArrayByteSource withFileName(String fileName) { ArgChecker.notNull(fileName, "fileName"); return new ArrayByteSource(array, Paths.get(fileName).getFileName().toString()); }

Target:
public ArrayByteSource withFileName(String fileName) { ArgChecker.notNull(fileName, "fileName"); int lastSlash = fileName.lastIndexOf('/'); return new ArrayByteSource(array, fileName.substring(lastSlash + 1)); }
Source:
public VerificationMethod getVerificationType() { Log.e("TAG", this.getVerificationMethod()); if(this.getVerificationMethod().equals("E")) { return VerificationMethod.EMAIL; } else if (this.getVerificationMethod().equals("M")) { return VerificationMethod.MOBILE; } else { return VerificationMethod.NONE; } }

Target:
public VerificationMethod getVerificationType() { if(this.getVerificationMethod().equals("E")) { return VerificationMethod.EMAIL; } else if (this.getVerificationMethod().equals("M")) { return VerificationMethod.MOBILE; } else { return VerificationMethod.NONE; } }
Source:
public Collection<? extends GrantedAuthority> getAuthorities(User user) { Set<GrantedAuthority> authorities = new LinkedHashSet<>(); if (user.isSuperuser() != null && user.isSuperuser()) { authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_SU)); } if (user.getUsername().equals(SecurityUtils.ANONYMOUS_USERNAME)) { authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_ANONYMOUS)); } else { authorities.add(new SimpleGrantedAuthority(AUTHORITY_USER)); } dataService.query(GROUP_MEMBERSHIP, GroupMembership.class) .eq(USER, user) .findAll() .filter(GroupMembership::isCurrentlyActive) .map(GroupMembership::getRole) .map(SidUtils::createRoleAuthority) .map(SimpleGrantedAuthority::new) .forEach(authorities::add); return grantedAuthoritiesMapper.mapAuthorities(authorities); }

Target:
public Collection<? extends GrantedAuthority> getAuthorities(User user) { Set<GrantedAuthority> authorities = new LinkedHashSet<>(); if (user.isSuperuser() != null && user.isSuperuser()) { authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_SU)); } if (user.getUsername().equals(SecurityUtils.ANONYMOUS_USERNAME)) { authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_ANONYMOUS)); } else { authorities.add(new SimpleGrantedAuthority(AUTHORITY_USER)); } dataService.query(ROLE_MEMBERSHIP, RoleMembership.class) .eq(USER, user) .findAll() .filter(RoleMembership::isCurrent) .map(RoleMembership::getRole) .map(SidUtils::createRoleAuthority) .map(SimpleGrantedAuthority::new) .forEach(authorities::add); return grantedAuthoritiesMapper.mapAuthorities(authorities); }
Source:
private <T> AnySuperTypeMatches(Predicate filter) { this.filter = filter; }

Target:
private AnySuperTypeMatches(Predicate filter) { this.filter = filter; }
Source:
public void testDefineBoolean() { db.getSharedHandle().setTemplateEngine(new StringTemplateEngine()); assertThat( db.getSharedHandle().createQuery("select <a> from values(:a<if(b)>, :b shouldn't be defined<endif>)") .defineNamedBindings() .bindBean(new DefinedBean()) .mapTo(boolean.class) .findOnly()) .isTrue(); }

Target:
public void testDefineBoolean() { db.getSharedHandle().setTemplateEngine(new StringTemplateEngine()); assertThat( db.getSharedHandle().createQuery("select <a> from values(:a) <if(b)>where false=:b<endif>") .defineNamedBindings() .bindBean(new DefinedBean()) .mapTo(boolean.class) .findOnly()) .isTrue(); }
Source:
private void read(SelectionKey key) throws InterruptedException, IOException { long startTimeInMs = SystemTime.getInstance().milliseconds(); try { SocketChannel socketChannel = (SocketChannel) key.channel(); BoundedByteBufferReceive input = null; if (key.attachment() == null) { input = new BoundedByteBufferReceive(); key.attach(input); } else { input = (BoundedByteBufferReceive) key.attachment(); } long bytesRead = input.readFrom(socketChannel); if (bytesRead == -1) { close(key); return; } logger.trace("bytes read from {}", socketChannel.socket().getRemoteSocketAddress()); if (input.isReadComplete()) { SocketServerRequest req = new SocketServerRequest(id, key, new ByteBufferInputStream(input.getPayload())); channel.sendRequest(req); key.attach(null); key.interestOps(key.interestOps() & (~SelectionKey.OP_READ)); logger.trace("resetting read interest for key for {}", ((SocketChannel) key.channel()).socket().getRemoteSocketAddress()); } else { if (logger.isTraceEnabled()) { logger.trace("Did not finish reading, registering for read again on connection {}", socketChannel.socket().getRemoteSocketAddress()); } key.interestOps(SelectionKey.OP_READ); wakeup(); } } finally { long readTime = SystemTime.getInstance().milliseconds() - startTimeInMs; logger.trace("SocketServer read piece of data from channel time = {}", readTime); } }

Target:
private void read(SelectionKey key) throws InterruptedException, IOException { long startTimeToReadInMs = SystemTime.getInstance().milliseconds(); try { SocketChannel socketChannel = (SocketChannel) key.channel(); BoundedByteBufferReceive input = null; if (key.attachment() == null) { input = new BoundedByteBufferReceive(); key.attach(input); } else { input = (BoundedByteBufferReceive) key.attachment(); } long bytesRead = input.readFrom(socketChannel); if (bytesRead == -1) { close(key); return; } logger.trace("bytes read from {}", socketChannel.socket().getRemoteSocketAddress()); if (input.isReadComplete()) { SocketServerRequest req = new SocketServerRequest(id, key, new ByteBufferInputStream(input.getPayload())); channel.sendRequest(req); key.attach(null); key.interestOps(key.interestOps() & (~SelectionKey.OP_READ)); logger.trace("resetting read interest for key for {}", ((SocketChannel) key.channel()).socket().getRemoteSocketAddress()); } else { if (logger.isTraceEnabled()) { logger.trace("Did not finish reading, registering for read again on connection {}", socketChannel.socket().getRemoteSocketAddress()); } key.interestOps(SelectionKey.OP_READ); wakeup(); } } finally { long readTime = SystemTime.getInstance().milliseconds() - startTimeToReadInMs; logger.trace("SocketServer time spent on read per key = {}", readTime); } }
Source:
public SuccessResponse updateInstanceTags( @ApiParam(value = "Instance name", required = true, example = "Server_a.b.com_20000 | Broker_my.broker.com_30000") @PathParam("instanceName") String instanceName, @ApiParam(value = "Comma separated tags list", required = true) @QueryParam("tags") String tags) { LOGGER.info("Instance update request received for instance: {}", instanceName); if (tags == null) { throw new ControllerApplicationException(LOGGER, "Must provide tags to update", Response.Status.BAD_REQUEST); } PinotResourceManagerResponse response = pinotHelixResourceManager.updateInstanceTags(instanceName, tags); if (!response.isSuccessful()) { throw new ControllerApplicationException(LOGGER, "Failure to update instance tags. Reason: " + response.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); } return new SuccessResponse("Instance successfully updated"); }

Target:
public SuccessResponse updateInstanceTags( @ApiParam(value = "Instance name", required = true, example = "Server_a.b.com_20000 | Broker_my.broker.com_30000") @PathParam("instanceName") String instanceName, @ApiParam(value = "Comma separated tags list", required = true) @QueryParam("tags") String tags) { LOGGER.info("Instance update request received for instance: and tags: {}", instanceName, tags); if (tags == null) { throw new ControllerApplicationException(LOGGER, "Must provide tags to update", Response.Status.BAD_REQUEST); } PinotResourceManagerResponse response = pinotHelixResourceManager.updateInstanceTags(instanceName, tags); if (!response.isSuccessful()) { throw new ControllerApplicationException(LOGGER, "Failure to update instance: " + instanceName + " with tags: " + tags + ". Reason: " + response.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); } return new SuccessResponse("Successfully updated tags for instance: " + instanceName + " tags: " + tags); }
Source:
public void multigetSliceChecksLimit() throws TException, LimitExceededException { client.multiget_slice("get", TEST_TABLE, ImmutableList.of(ROW_KEY), SLICE_PREDICATE, ConsistencyLevel.ANY); verify(qosClient, times(1)).executeRead(any(), any(), any()); verifyNoMoreInteractions(qosClient); }

Target:
public void multigetSliceChecksLimit() throws TException, LimitExceededException { client.multiget_slice("get", TEST_TABLE, ImmutableList.of(ROW_KEY), SLICE_PREDICATE, ConsistencyLevel.ANY); verify(qosClient, times(1)).executeRead(any(), any()); verifyNoMoreInteractions(qosClient); }
Source:
public void onCreate() { PRNGFixes.apply(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (!sp.getBoolean("default_user_pw_set", false)) { sp.edit().putBoolean("default_user_pw_set", true).commit(); char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray(); StringBuilder sb = new StringBuilder(); SecureRandom random = new SecureRandom(); for (int i = 0; i < 20; i++) sb.append(chars[random.nextInt(chars.length)]); String user = Build.MODEL.replaceAll("[^a-zA-Z0-9 ]", ""); Log.i(TAG, "Generated GUI username and password (username is " + user + ")"); sp.edit().putString("gui_user", user) .putString("gui_password", sb.toString()).commit(); } mDeviceStateHolder = new DeviceStateHolder(SyncthingService.this); registerReceiver(mDeviceStateHolder, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); new StartupTask().execute(); }

Target:
public void onCreate() { PRNGFixes.apply(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (!sp.getBoolean("default_user_pw_set", false)) { sp.edit().putBoolean("default_user_pw_set", true).commit(); char[] chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray(); StringBuilder sb = new StringBuilder(); SecureRandom random = new SecureRandom(); for (int i = 0; i < 20; i++) sb.append(chars[random.nextInt(chars.length)]); String user = Build.MODEL.replaceAll("[^a-zA-Z0-9 ]", ""); Log.i(TAG, "Generated GUI username and password (username is " + user + ")"); sp.edit().putString("gui_user", user) .putString("gui_password", sb.toString()).commit(); } mDeviceStateHolder = new DeviceStateHolder(SyncthingService.this); registerReceiver(mDeviceStateHolder, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); new StartupTask().execute(); }
Source:
public void writeEventValue(@NonNull final IEvent event, final T value) { SharedPreferences.Editor editor = sharedPreferences.edit(); if (value.getClass().equals(String.class)) { editor.putString(event.getTrackingKey(), (String) value); } else if (value.getClass().equals(Boolean.class)) { editor.putBoolean(event.getTrackingKey(), (Boolean) value); } else if (value.getClass().equals(Long.class)) { editor.putLong(event.getTrackingKey(), (Long) value); } else if (value.getClass().equals(Integer.class)) { editor.putInt(event.getTrackingKey(), (Integer) value); } else if (value.getClass().equals(Float.class)) { editor.putLong(event.getTrackingKey(), (Long) value); } editor.apply(); }

Target:
public void writeEventValue(@NonNull final IEvent event, final T value) { SharedPreferences.Editor editor = sharedPreferences.edit(); if (value.getClass().equals(String.class)) { editor.putString(event.getTrackingKey(), (String) value); } else if (value.getClass().equals(Boolean.class)) { editor.putBoolean(event.getTrackingKey(), (Boolean) value); } else if (value.getClass().equals(Long.class)) { editor.putLong(event.getTrackingKey(), (Long) value); } else if (value.getClass().equals(Integer.class)) { editor.putInt(event.getTrackingKey(), (Integer) value); } else if (value.getClass().equals(Float.class)) { editor.putLong(event.getTrackingKey(), (Long) value); } else { throw new IllegalArgumentException("Event value must be one of String, Boolean, Long, Integer or Float"); } editor.apply(); }
Source:
public LinkedHashMap<String, String> getAPIPacketParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("Device Request ID", String.valueOf(requestID)); parameters.put("Transport", HexUtils.prettyHexString(HexUtils.integerToHexString(transport, 1))); parameters.put("Flags", HexUtils.prettyHexString(HexUtils.integerToHexString(flags, 1))); if (target != null) { parameters.put("Target length", String.valueOf(target.length())); parameters.put("Target", target); } else parameters.put("Target length", "0"); if (requestData != null) parameters.put("Data", HexUtils.prettyHexString(HexUtils.byteArrayToHexString(requestData))); return parameters; }

Target:
public LinkedHashMap<String, String> getAPIPacketParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("Device Request ID", HexUtils.prettyHexString(HexUtils.integerToHexString(requestID, 1)) + " (" + requestID + ")"); parameters.put("Transport", HexUtils.prettyHexString(HexUtils.integerToHexString(transport, 1))); parameters.put("Flags", HexUtils.prettyHexString(HexUtils.integerToHexString(flags, 1))); if (target != null) { parameters.put("Target length", HexUtils.prettyHexString(HexUtils.integerToHexString(target.length(), 1)) + " (" + target.length() + ")"); parameters.put("Target", HexUtils.prettyHexString(HexUtils.byteArrayToHexString(target.getBytes())) + " (" + target + ")"); } else parameters.put("Target length", HexUtils.prettyHexString(HexUtils.integerToHexString(0, 1)) + " (0)"); if (requestData != null) parameters.put("Data", HexUtils.prettyHexString(HexUtils.byteArrayToHexString(requestData))); return parameters; }
Source:
private String columnDefinitionsString(ResultHandler.ComparableColumnDefinitions cd) { StringBuilder sb = new StringBuilder(); if (cd == null) { sb.append("NULL"); } else if (cd.wasFailed()) { sb.append("FAILED"); } else { for (ResultHandler.ComparableDefinition def : cd) { sb.append(def.toString()); } } return sb.toString(); }

Target:
private String columnDefinitionsString(ResultHandler.ComparableColumnDefinitions cd) { StringBuilder sb = new StringBuilder(); if (cd == null) sb.append("NULL"); else if (cd.wasFailed()) sb.append("FAILED"); else { for (ResultHandler.ComparableDefinition def : cd) { sb.append(def.toString()); } } return sb.toString(); }
Source:
public void setMenuItems(@Nullable List<CarMenuItem> items) { mMenuItems = items; mAllMenuItems.clear(); mAlwaysItemCount = 0; if (mMenuItems == null) { requestLayout(); return; } for (int i = 0; i < mMenuItems.size(); i++) { CarMenuItem item = mMenuItems.get(i); View action = null; if (item.getDisplayBehavior() == CarMenuItem.DisplayBehavior.ALWAYS || item.getDisplayBehavior() == CarMenuItem.DisplayBehavior.IF_ROOM) { action = item.isCheckable() ? createCheckableAction(item) : createAction(item); } if (item.getDisplayBehavior() == CarMenuItem.DisplayBehavior.ALWAYS) { mAlwaysItemCount++; } mAllMenuItems.add(new InflatedMenuItem(item, action)); } requestLayout(); }

Target:
public void setMenuItems(@Nullable List<CarMenuItem> items) { mMenuItems = items; mAllMenuItems.clear(); mAlwaysItemCount = 0; if (mMenuItems == null) { requestLayout(); return; } for (CarMenuItem item : mMenuItems) { View action; switch (item.getDisplayBehavior()) { case ALWAYS: mAlwaysItemCount++; case IF_ROOM: action = item.isCheckable() ? createCheckableAction(item) : createAction(item); break; case NEVER: action = null; break; default: throw new IllegalStateException( "Unknown display behavior: " + item.getDisplayBehavior()); } mAllMenuItems.add(new InflatedMenuItem(item, action)); } requestLayout(); }
Source:
private void handleFindNewFansMessage(final String remoteAddr) { Toaster.iToast(this, R.string.finding_new_fans); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter == null) { Toaster.eToast(this, "Bluetooth adapter is null"); return; } BluetoothDevice remoteDevice = adapter.getRemoteDevice(remoteAddr); MessageThread found = null; for (MessageThread thread : this.messageThreads) { if (thread.isRemoteDevice(remoteDevice)) { found = thread; break; } } if (found == null) { Toaster.eToast(this, "Unknown remote device."); return; } this.discoveryInitiator = found; adapter.startDiscovery(); }

Target:
private void handleFindNewFansMessage(final String remoteAddr) { Toaster.iToast(this, R.string.finding_new_fans); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice remoteDevice = adapter.getRemoteDevice(remoteAddr); MessageThread found = null; for (MessageThread thread : this.messageThreads) { if (thread.isRemoteDevice(remoteDevice)) { found = thread; break; } } if (found == null) { Log.wtf(TAG, "Unknown remote device: " + remoteAddr); return; } this.discoveryInitiator = found; adapter.startDiscovery(); }
Source:
private void parseRewind(final ReceiveCommand cmd) { RevCommit newObject; try { newObject = rp.getRevWalk().parseCommit(cmd.getNewId()); } catch (IncorrectObjectTypeException notCommit) { newObject = null; } catch (IOException err) { log.error("Invalid object " + cmd.getNewId().name() + " for " + cmd.getRefName() + " forced update", err); reject(cmd, "invalid object"); return; } RefControl ctl = projectControl.controlForRef(cmd.getRefName()); if (newObject != null) { validateNewCommits(ctl, cmd); if (cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED) { return; } } if (ctl.canForceUpdate()) { } else { cmd.setResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD); reject(cmd, "For non-fast forward updates, '" + PermissionRule.FORCE_PUSH + "' privilege is needed"); } }

Target:
private void parseRewind(final ReceiveCommand cmd) { RevCommit newObject; try { newObject = rp.getRevWalk().parseCommit(cmd.getNewId()); } catch (IncorrectObjectTypeException notCommit) { newObject = null; } catch (IOException err) { log.error("Invalid object " + cmd.getNewId().name() + " for " + cmd.getRefName() + " forced update", err); reject(cmd, "invalid object"); return; } RefControl ctl = projectControl.controlForRef(cmd.getRefName()); if (newObject != null) { validateNewCommits(ctl, cmd); if (cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED) { return; } } if (ctl.canForceUpdate()) { } else { cmd.setResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD, " need '" + PermissionRule.FORCE_PUSH + "' privilege."); } }
Source:
@Override public void reportProcessingUpdate( final ReportProgressEvent reportProgressEvent ) { final int page; if ( asyncReportListener.getRequestedPage() > 0 ) { page = Math.max( asyncReportListener.getRequestedPage() + 2, reportProgressEvent.getPage() ); } else { page = acceptedPage + 2; } final boolean requestedPageIsStored = reportProgressEvent.getPage() == page; if ( reportProgressEvent.getActivity() == ReportProgressEvent.GENERATING_CONTENT && requestedPageIsStored ) { try { persistContent( key, produceReportContent( proc, targetRepository ) ); } catch ( final Exception e ) { logger.error( "Can't persist" ); } asyncReportListener.updateGenerationStatus( page - 1 ); asyncReportListener.setStatus( AsyncExecutionStatus.CONTENT_AVAILABLE ); } }

Target:
@Override public void reportProcessingUpdate( final ReportProgressEvent reportProgressEvent ) { final int page; if ( asyncReportListener.getRequestedPage() > 0 ) { page = Math.max( asyncReportListener.getRequestedPage() + 2, reportProgressEvent.getPage() ); } else { page = acceptedPage + 2; } final boolean needToStorePages = reportProgressEvent.getPage() == page && reportProgressEvent.getPage() > lastAcceptedPageWritten; if ( reportProgressEvent.getActivity() == ReportProgressEvent.GENERATING_CONTENT && needToStorePages ) { try { persistContent( key, produceReportContent( proc, targetRepository ) ); lastAcceptedPageWritten = page; asyncReportListener.updateGenerationStatus( page - 1 ); asyncReportListener.setStatus( AsyncExecutionStatus.CONTENT_AVAILABLE ); } catch ( final Exception e ) { logger.error( "Can't persist" ); } } }
Source:
public Optional<String> getExtension() { return Optional.fromNullable(extension); }

Target:
public Optional<String> getExtension() { return extension; }
Source:
public WallboardBody() { addStyleName("wallboard-board"); setSizeFull(); contentLayout = new CssLayout(); contentLayout.setSizeFull(); contentLayout.addComponent(new Label("Nothing to display")); if (debugEnabled) { addComponent(debugLabel); } addComponent(contentLayout); progressIndicator = new ProgressIndicator(); progressIndicator.setWidth("100%"); progressIndicator.setPollingInterval(250); progressIndicator.setVisible(true); addComponent(progressIndicator); setExpandRatio(contentLayout, 0.95f); setExpandRatio(progressIndicator, 0.05f); timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { final UI ui = getUI(); if (ui != null) { getUI().accessSynchronously(new Runnable() { @Override public void run() { advanceTimer(); } }); } } }, 250, 250); addDetachListener(new DetachListener() { @Override public void detach(DetachEvent detachEvent) { timer.cancel(); } }); }

Target:
public WallboardBody() { addStyleName("wallboard-board"); setSizeFull(); contentLayout = new CssLayout(); contentLayout.setSizeFull(); contentLayout.addComponent(new Label("Nothing to display")); if (debugEnabled) { addComponent(debugLabel); } addComponent(contentLayout); setExpandRatio(contentLayout, 1.0f); progressIndicator = new ProgressIndicator(); progressIndicator.setWidth("100%"); progressIndicator.setPollingInterval(250); progressIndicator.setVisible(false); addComponent(progressIndicator); timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { final UI ui = getUI(); if (ui != null) { ui.accessSynchronously(new Runnable() { @Override public void run() { advanceTimer(); } }); } } }, 250, 250); addDetachListener(new DetachListener() { @Override public void detach(DetachEvent detachEvent) { timer.cancel(); } }); }
Source:
private void running() { try { while( fState == TimerThreadState.RUNNING ) { long timeout = getWaitTimeout(); QueueEntry entry = fQueue.peek(); if ( entry != null ) { long commandTimeout = getTimeoutForCommand( entry.fCommandToken.getCommand() ); if ( DEBUG ) { String commandText = entry.fCommandToken.getCommand().toString(); if ( commandText.endsWith( "\n" ) ) commandText = commandText.substring( 0, commandText.length() - 1 ); printDebugMessage( String.format( "Processing command '%s', command timeout is %d", commandText, Long.valueOf( commandTimeout ) ) ); } long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - entry.fTimestamp; if ( commandTimeout <= elapsedTime ) { processTimedOutCommand( entry.fCommandToken ); fQueue.remove( entry ); QueueEntry nextEntry = fQueue.peek(); if ( nextEntry != null ) { setTimeStamp( currentTime, nextEntry ); } } else { timeout = Math.min( timeout, commandTimeout - elapsedTime ); if ( DEBUG ) { String commandText = entry.fCommandToken.getCommand().toString(); if ( commandText.endsWith( "\n" ) ) commandText = commandText.substring( 0, commandText.length() - 1 ); printDebugMessage( String.format( "Setting timeout %d for command '%s'", Long.valueOf( timeout ), commandText ) ); } } } synchronized( TimerThread.this ) { wait( timeout ); } if ( isInterrupted() ) { } } } catch( InterruptedException e ) { } }

Target:
private void running() { try { while( getTimerThreadState() == TimerThreadState.RUNNING ) { long timeout = getWaitTimeout(); QueueEntry entry = fQueue.peek(); if ( entry != null ) { long commandTimeout = getTimeoutForCommand( entry.fCommandToken.getCommand() ); if ( DEBUG ) { String commandText = entry.fCommandToken.getCommand().toString(); if ( commandText.endsWith( "\n" ) ) commandText = commandText.substring( 0, commandText.length() - 1 ); printDebugMessage( String.format( "Processing command '%s', command timeout is %d", commandText, Long.valueOf( commandTimeout ) ) ); } long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - entry.fTimestamp; if ( commandTimeout <= elapsedTime ) { processTimedOutCommand( entry.fCommandToken ); fQueue.remove( entry ); QueueEntry nextEntry = fQueue.peek(); if ( nextEntry != null ) { setTimeStamp( currentTime, nextEntry ); } } else { timeout = Math.min( timeout, commandTimeout - elapsedTime ); if ( DEBUG ) { String commandText = entry.fCommandToken.getCommand().toString(); if ( commandText.endsWith( "\n" ) ) commandText = commandText.substring( 0, commandText.length() - 1 ); printDebugMessage( String.format( "Setting timeout %d for command '%s'", Long.valueOf( timeout ), commandText ) ); } } } synchronized( TimerThread.this ) { wait( timeout ); } } } catch( InterruptedException e ) { } }
Source:
public boolean isSelected(File basedir, String filename, File file) throws BuildException { String parentName = file.getParent(); if (parentName.length() > baseDirPathLength) { String parentRelativeName = parentName.substring(baseDirPathLength + File.separator.length()); if (alreadyDeselected.contains(parentRelativeName)) { alreadyDeselected.add(filename); return false; } } if (file.isDirectory()) { try { if (baseDirFP.isDescendant(filename)) { return true; } else { alreadyDeselected.add(filename); return false; } } catch (IOException | InterruptedException e) { return true; } } else { return true; } }

Target:
public boolean isSelected(File basedir, String filename, File file) throws BuildException { String parentName = file.getParent(); if (parentName.length() > baseDirPathLength) { String parentRelativeName = parentName.substring(baseDirPathLength + 1); if (alreadyDeselected.contains(parentRelativeName)) { alreadyDeselected.add(filename); return false; } } if (file.isDirectory()) { try { if (baseDirFP.isDescendant(filename)) { return true; } else { alreadyDeselected.add(filename); return false; } } catch (IOException | InterruptedException e) { return true; } } else { return true; } }
Source:
public void onActionModeShown(ActionMode mode) { if (model.getPage() == null) { return; } shareHandler.onTextSelected(mode); }

Target:
public void onActionModeShown(ActionMode mode) { if (model.getPage() != null) { shareHandler.onTextSelected(mode); } }
Source:
private Map<String, List<Endorsement>> groupEndorsementsByTechnology( List<Endorsement> endorsementsList) { Map<String, List<Endorsement>> groupedEndorsements = new HashMap<String, List<Endorsement>>(); for (Endorsement endorsement : endorsementsList) { String key = endorsement.getTechnologyEntity().getName(); List<Endorsement> group = groupedEndorsements.get(key); if (group == null) { group = new ArrayList<Endorsement>(); } group.add(endorsement); groupedEndorsements.put(key, group); } return groupedEndorsements; }

Target:
private Map<String, List<Endorsement>> groupEndorsementsByTechnology( List<Endorsement> endorsementsList) { Map<String, List<Endorsement>> groupedEndorsements = new HashMap<String, List<Endorsement>>(); for (Endorsement endorsement : endorsementsList) { String key = endorsement.getTechnologyEntity().getName(); List<Endorsement> group = groupedEndorsements.get(key); if (group == null) { group = new ArrayList<Endorsement>(); groupedEndorsements.put(key, group); } group.add(endorsement); } return groupedEndorsements; }
Source:
public List<T> get() { try { for (final ServiceReference<T> ref : this.serviceReferences) { final T service = this.bundleContext.getService(ref); if (service != null) { this.acquiredServices.put(service, ref); } } } catch (final Exception ex) { logger.warn(message.errorRetrievingService(), ex); } return unmodifiableList(new ArrayList<>(this.acquiredServices.keySet())); }

Target:
public Stream<T> get() { if (this.isClosed.get()) { throw new IllegalStateException(message.alreadyClosed()); } serviceTracker.ifPresent(t -> { if (isTrackerOpened.compareAndSet(false, true)) { t.open(); } if (shouldWait) { final long timeoutInMillis = timeUnit.toMillis(timeout); try { t.waitForService(timeoutInMillis); } catch (final InterruptedException e) { } } final ServiceReference<T>[] refs = t.getServiceReferences(); if (nonNull(refs)) { serviceReferences.addAll(Arrays.stream(refs).collect(Collectors.toList())); } }); try { this.serviceReferences.stream().filter(this::isNotAcquired).forEach(this::acquireService); } catch (final Exception ex) { logger.error(message.errorRetrievingService(), ex); } return this.acquiredServices.values().stream(); }
Source:
public NullnessJspecifySamplesTest(List<File> testFiles) { super( testFiles, org.checkerframework.checker.nullness.NullnessChecker.class, "nullness", Collections.singletonList("../../jspecify/build/libs/jspecify-0.1.0-SNAPSHOT.jar"), "-Anomsgtext"); }

Target:
public NullnessJspecifySamplesTest(List<File> testFiles) { super( testFiles, org.checkerframework.checker.nullness.NullnessChecker.class, "../../../jspecify/samples", Collections.singletonList("../../jspecify/build/libs/jspecify-0.1.0-SNAPSHOT.jar"), "-Anomsgtext"); }
Source:
protected DatanodeDetails chooseNodeFromNetworkTopology( NetworkTopology networkTopology, DatanodeDetails anchor, List<DatanodeDetails> excludedNodes) { if (networkTopology == null) { return null; } if (excludedNodes == null) { return (DatanodeDetails)networkTopology.chooseRandom( anchor.getNetworkFullPath(), new ArrayList<>()); } Collection<Node> excluded = new ArrayList<>(); excluded.add(anchor); Node pick; Node pick1 = networkTopology.chooseRandom( anchor.getNetworkLocation(), excluded); if (pick1 == null) { return null; } Node pick2 = networkTopology.chooseRandom( anchor.getNetworkLocation(), excluded); if (pick2 == null) { pick = pick1; } else { pick = (networkTopology.getDistanceCost(anchor, pick1) > networkTopology.getDistanceCost(anchor, pick2)) ? pick2 : pick1; } DatanodeDetails pickedNode = (DatanodeDetails) pick; excludedNodes.add(pickedNode); return pickedNode; }

Target:
protected DatanodeDetails chooseNodeFromNetworkTopology( NetworkTopology networkTopology, DatanodeDetails anchor, List<DatanodeDetails> excludedNodes) { Preconditions.checkArgument(networkTopology != null); Collection<Node> excluded = new ArrayList<>(); if (excludedNodes != null && excludedNodes.size() != 0) { excluded.addAll(excludedNodes); } excluded.add(anchor); Node pick = networkTopology.chooseRandom( anchor.getNetworkLocation(), excluded); DatanodeDetails pickedNode = (DatanodeDetails) pick; if (excludedNodes != null) { excludedNodes.add(pickedNode); } return pickedNode; }
Source:
public static URL getResourceRoot(String name) throws IOException { URL url = ResourceLoader.class.getResource("/" + name); if (url == null) { try { return new URL("modjar://worldedit/" + name); } catch (Exception e) { } throw new IOException("Could not find " + name); } return url; }

Target:
public static URL getResourceRoot(String name) throws IOException { URL url = ResourceLoader.class.getResource("/" + name); if (url == null) { return getResourceForgeHack(name); } return url; }
Source:
public TableLayout getLayout(Session session, TableHandle handle) { ConnectorId connectorId = handle.getConnectorId(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId); ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(connectorId); return fromConnectorLayout(connectorId, transaction, metadata.getTableLayout(session.toConnectorSession(connectorId), resolveTableLayout(session, handle))); }

Target:
public TableLayout getLayout(Session session, TableHandle handle) { ConnectorId connectorId = handle.getConnectorId(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId); return fromConnectorLayout(connectorId, handle.getConnectorHandle(), handle.getTransaction(), metadata.getTableLayout(session.toConnectorSession(connectorId), resolveTableLayout(session, handle))); }
Source:
public StatusDTO setKeycloakRealm(String keycloakRealm) { this.keycloakRealm = keycloakRealm; return this; }

Target:
public KeycloakStatusDTO setKeycloakRealm(String keycloakRealm) { this.keycloakRealm = keycloakRealm; return this; }
Source:
private void processGetBlobResponse(GetRequestInfo getRequestInfo, GetResponse getResponse) throws IOException, MessageFormatException { ServerErrorCode getError = getResponse.getError(); if (getError == ServerErrorCode.No_Error) { int partitionsInResponse = getResponse.getPartitionResponseInfoList().size(); if (partitionsInResponse != 1) { chunkException = new RouterException( "Unexpected number of partition responses, expected: 1, " + "received: " + partitionsInResponse, RouterErrorCode.UnexpectedInternalError); } else { getError = getResponse.getPartitionResponseInfoList().get(0).getErrorCode(); if (getError == ServerErrorCode.No_Error) { handleBody(getResponse.getInputStream()); chunkOperationTracker.onResponse(getRequestInfo.replicaId, true); if (RouterUtils.isRemoteReplica(routerConfig, getRequestInfo.replicaId)) { logger.trace("Cross colo request successful for remote replica in ", getRequestInfo.replicaId.getDataNodeId().getDatacenterName()); routerMetrics.crossColoSuccessCount.inc(); } } else { processServerError(getError); if (getError == ServerErrorCode.Blob_Deleted || getError == ServerErrorCode.Blob_Expired) { chunkCompleted = true; retainExceptionOnSuccess = true; } else { onErrorResponse(getRequestInfo.replicaId); } } } } else { onErrorResponse(getRequestInfo.replicaId); } }

Target:
private void processGetBlobResponse(GetRequestInfo getRequestInfo, GetResponse getResponse) throws IOException, MessageFormatException { ServerErrorCode getError = getResponse.getError(); if (getError == ServerErrorCode.No_Error) { int partitionsInResponse = getResponse.getPartitionResponseInfoList().size(); if (partitionsInResponse != 1) { chunkException = new RouterException( "Unexpected number of partition responses, expected: 1, " + "received: " + partitionsInResponse, RouterErrorCode.UnexpectedInternalError); } else { getError = getResponse.getPartitionResponseInfoList().get(0).getErrorCode(); if (getError == ServerErrorCode.No_Error) { handleBody(getResponse.getInputStream()); chunkOperationTracker.onResponse(getRequestInfo.replicaId, true); if (RouterUtils.isRemoteReplica(routerConfig, getRequestInfo.replicaId)) { logger.trace("Cross colo request successful for remote replica in ", getRequestInfo.replicaId.getDataNodeId().getDatacenterName()); routerMetrics.crossColoSuccessCount.inc(); } } else { processServerError(getError); if (getError == ServerErrorCode.Blob_Deleted || getError == ServerErrorCode.Blob_Expired) { chunkCompleted = true; } else { onErrorResponse(getRequestInfo.replicaId); } } } } else { onErrorResponse(getRequestInfo.replicaId); } }
Source:
protected void adaptLONConfiguration(BackupConfigurationBuilder builder) { builder.stateTransfer().chunkSize(2).timeout(2000).maxRetries(2); }

Target:
protected void adaptLONConfiguration(BackupConfigurationBuilder builder) { builder.stateTransfer().chunkSize(2).timeout(2000).maxRetries(1); }
Source:
public void clearDependencies() { super.clearDependencies(); taskSourceRdd = null; inputRdds = null; taskProcessor = null; }

Target:
public void clearDependencies() { super.clearDependencies(); shuffleInputFragmentIds = null; shuffleInputRdds = null; taskSourceRdd = null; taskProcessor = null; }
Source:
private List<String> getColumnMetadata(String parent, JsonNode propertiesNode) { List<String> metadata = new ArrayList<>(); Iterator<Entry<String, JsonNode>> iterator = propertiesNode.fields(); while (iterator.hasNext()) { Entry<String, JsonNode> entry = iterator.next(); String key = entry.getKey(); JsonNode value = entry.getValue(); String childKey = null; if (parent == null || parent.isEmpty()) { childKey = key; } else { childKey = parent.concat(".").concat(key); } if (value.isObject()) { metadata.addAll(getColumnMetadata(childKey, value)); continue; } if (!value.isArray()) { metadata.add(childKey.concat(":").concat(value.textValue())); } } return metadata; }

Target:
private List<String> getColumnMetadata(String parent, JsonNode propertiesNode) { List<String> metadata = new ArrayList<>(); Iterator<Entry<String, JsonNode>> iterator = propertiesNode.fields(); while (iterator.hasNext()) { Entry<String, JsonNode> entry = iterator.next(); String key = entry.getKey(); JsonNode value = entry.getValue(); String childKey; if (parent == null || parent.isEmpty()) { childKey = key; } else { childKey = parent.concat(".").concat(key); } if (value.isObject()) { metadata.addAll(getColumnMetadata(childKey, value)); continue; } if (!value.isArray()) { metadata.add(childKey.concat(":").concat(value.textValue())); } } return metadata; }
Source:
public static void executeBuild() throws Exception { System.setProperty("verifier.forkMode", "auto"); verifier = new RepoRefLocationP2RepositoryIntegrationTest().getVerifier("/p2Repository.repositoryRef.location", false); verifier.getCliOptions().add("-Dtest-data-repo=" + ResourceUtil.P2Repositories.ECLIPSE_OXYGEN.toString()); verifier.executeGoal("verify"); verifier.verifyErrorFreeLog(); p2Repo = P2RepositoryTool.forEclipseRepositoryModule(new File(verifier.getBasedir())); }

Target:
public static void executeBuild() throws Exception { System.setProperty("verifier.forkMode", "auto"); verifier = new RepoRefLocationP2RepositoryIntegrationTest().getVerifier("/p2Repository.repositoryRef.location", false); verifier.getCliOptions().add("-Dtest-data-repo=" + ResourceUtil.P2Repositories.ECLIPSE_OXYGEN.toString()); verifier.executeGoal("package"); verifier.verifyErrorFreeLog(); p2Repo = P2RepositoryTool.forEclipseRepositoryModule(new File(verifier.getBasedir())); }
Source:
private DatasetExportService getExportFileStrategy(final String fileType) { if (DatasetResource.CSV.equalsIgnoreCase(fileType.trim())) { return this.datasetCSVExportServiceImpl; } else if (DatasetResource.XLS.equalsIgnoreCase(fileType.trim())) { return this.datasetExcelExportServiceImpl; } else if (DatasetResource.KSU_CSV.equalsIgnoreCase(fileType.trim())) { return this.datasetKSUCSVExportServiceImpl; } else if (DatasetResource.KSU_XLS.equalsIgnoreCase(fileType.trim())) { return this.datasetKSUExcelExportServiceImpl; } return null; }

Target:
private DatasetExportService getExportFileStrategy(final String fileType) { final String trimmedFileType = fileType.trim(); if (DatasetResource.CSV.equalsIgnoreCase(trimmedFileType)) { return this.datasetCSVExportServiceImpl; } else if (DatasetResource.XLS.equalsIgnoreCase(trimmedFileType)) { return this.datasetExcelExportServiceImpl; } else if (DatasetResource.KSU_CSV.equalsIgnoreCase(trimmedFileType)) { return this.datasetKsuCSVExportServiceImpl; } else if (DatasetResource.KSU_XLS.equalsIgnoreCase(trimmedFileType)) { return this.datasetKsuExcelExportServiceImpl; } return null; }
Source:
private LinkedList<Event> computeEventCounts(ObjectStream<Event> eventStream, Map<String, Integer> predicatesInOut, int cutoff) throws IOException { Set<String> predicateSet = new HashSet<>(); Map<String, Integer> counter = new HashMap<>(); LinkedList<Event> events = new LinkedList<>(); Event ev; while ((ev = eventStream.read()) != null) { events.addLast(ev); update(ev.getContext(), predicateSet, counter, cutoff); } predCounts = new int[predicateSet.size()]; int index = 0; for (Iterator<String> pi = predicateSet.iterator(); pi.hasNext(); index++) { String predicate = pi.next(); predCounts[index] = counter.get(predicate); predicatesInOut.put(predicate, index); } return events; }

Target:
private List<Event> computeEventCounts(ObjectStream<Event> eventStream, Map<String, Integer> predicatesInOut, int cutoff) throws IOException { Set<String> predicateSet = new HashSet<>(); Map<String, Integer> counter = new HashMap<>(); List<Event> events = new LinkedList<>(); Event ev; while ((ev = eventStream.read()) != null) { events.add(ev); update(ev.getContext(), predicateSet, counter, cutoff); } predCounts = new int[predicateSet.size()]; int index = 0; for (Iterator<String> pi = predicateSet.iterator(); pi.hasNext(); index++) { String predicate = pi.next(); predCounts[index] = counter.get(predicate); predicatesInOut.put(predicate, index); } return events; }
Source:
public static int getPercentCompleteSMAState(IAtsObject atsObject) throws OseeCoreException { if (atsObject instanceof IAtsAction) { IAtsAction action = (IAtsAction) atsObject; if (AtsCore.getWorkItemService().getTeams(action).size() == 1) { return getPercentCompleteSMAState(AtsCore.getWorkItemService().getFirstTeam(action)); } else { double percent = 0; int items = 0; for (IAtsTeamWorkflow team : AtsCore.getWorkItemService().getTeams(action)) { if (!AtsCore.getWorkItemService().getWorkData(team).isCancelled()) { percent += getPercentCompleteSMAState(team); items++; } } if (items > 0) { Double rollPercent = percent / items; return rollPercent.intValue(); } } return 0; } if (atsObject instanceof IAtsWorkItem) { return getPercentCompleteSMAState(atsObject, AtsCore.getWorkItemService().getCurrentState((IAtsWorkItem) atsObject)); } return 0; }

Target:
public static int getPercentCompleteSMAState(IAtsObject atsObject) throws OseeCoreException { int percent = 0; if (atsObject instanceof IAtsAction) { IAtsAction action = (IAtsAction) atsObject; if (AtsCore.getWorkItemService().getTeams(action).size() == 1) { return getPercentCompleteSMAState(AtsCore.getWorkItemService().getFirstTeam(action)); } else { int items = 0; for (IAtsTeamWorkflow team : AtsCore.getWorkItemService().getTeams(action)) { if (!AtsCore.getWorkItemService().getWorkData(team).isCancelled()) { percent += getPercentCompleteSMAState(team); items++; } } if (items > 0) { Double rollPercent = new Double(percent) / items; percent = rollPercent.intValue(); } } } else if (atsObject instanceof IAtsWorkItem) { return getPercentCompleteSMAState(atsObject, AtsCore.getWorkItemService().getCurrentState((IAtsWorkItem) atsObject)); } return percent; }