auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Class<?> resolveClass(final Unmarshaller unmarshaller, final String className, final long serialVersionUID) throws IOException, ClassNotFoundException { final String name = (String) unmarshaller.readObject(); if (name == null) { final ClassLoader classLoader; if (System.getSecurityManager() == null) { <START> classLoader = Module.class.getClassLoader(); <END> } else { classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return Module.class.getClassLoader(); } }); } return Class.forName(className, false, classLoader); } final String slot = (String) unmarshaller.readObject(); final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot); try { final ClassLoader classLoader; final Module module = moduleLoader.loadModule(identifier); if (System.getSecurityManager() == null) { classLoader = module.getClassLoader(); } else { classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return module.getClassLoader(); } }); } return Class.forName(className, false, classLoader); } catch (ModuleLoadException e) { final InvalidClassException ce = new InvalidClassException(className, "Module load failed"); ce.initCause(e); throw ce; } }</code><technical_language>This cached in a constant field</technical_language>

Target:
public Class<?> resolveClass(final Unmarshaller unmarshaller, final String className, final long serialVersionUID) throws IOException, ClassNotFoundException { final String name = (String) unmarshaller.readObject(); if (name == null) { return Class.forName(className, false, MODULE_CLASS_LOADER); } final String slot = (String) unmarshaller.readObject(); final ModuleIdentifier identifier = ModuleIdentifier.create(name, slot); try { final ClassLoader classLoader; final Module module = moduleLoader.loadModule(identifier); if (System.getSecurityManager() == null) { classLoader = module.getClassLoader(); } else { classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return module.getClassLoader(); } }); } return Class.forName(className, false, classLoader); } catch (ModuleLoadException e) { final InvalidClassException ce = new InvalidClassException(className, "Module load failed"); ce.initCause(e); throw ce; } }
Source:
<code>public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 401: case 403: exception = new AuthorizationException(message, exception); break; case 404: if (!command.getCurrentRequest().getMethod().equals("DELETE")) { exception = new ResourceNotFoundException(message, exception); } break; case 500: if (message != null ){ if (message.indexOf("Unable to determine package for") != -1) { exception = new ResourceNotFoundException(message, exception); } else if (message.indexOf("currently an active transaction") != -1) { exception = new IllegalStateException(message, exception); } else if (message.indexOf("SoftLayer_Exception_Order_Item_Duplicate") != -1) { <START> exception = new SoftLayerOrderItemDuplicateException(command.getCurrentRequest(), message); <END> } } } } finally { Closeables.closeQuietly(response.getPayload()); command.setException(exception); } }</code><technical_language>+1 - if exception is recognize a failure state, need more heavyweight information that</technical_language>

Target:
public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 401: case 403: exception = new AuthorizationException(message, exception); break; case 404: if (!command.getCurrentRequest().getMethod().equals("DELETE")) { exception = new ResourceNotFoundException(message, exception); } break; case 500: if (message != null ){ if (message.indexOf("Unable to determine package for") != -1) { exception = new ResourceNotFoundException(message, exception); } else if (message.indexOf("currently an active transaction") != -1) { exception = new IllegalStateException(message, exception); } else if (message.indexOf("SoftLayer_Exception_Order_Item_Duplicate") != -1) { exception = new SoftLayerOrderItemDuplicateException(message, exception); } } } } finally { Closeables.closeQuietly(response.getPayload()); command.setException(exception); } }
Source:
<code>protected RelNode visitChild(RelNode parent, int i, RelNode child) { <START> child.accept(this); <END> parent.getCluster().setMetadataProvider(metadataProvider); return parent; }</code><technical_language>here: refer L55 of calcite/core/src/main/java/org/apache/calcite/rel/RelShuttleImpl.java. accept method change this instance; returns a modified copy of child, discarded</technical_language>

Target:
protected RelNode visitChild(RelNode parent, int i, RelNode child) { parent = super.visitChild(parent, i, child); parent.getCluster().setMetadataProvider(metadataProvider); return parent; }
Source:
<code>public void recognizeBatchEntities() { List<TextDocumentInput> textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), new TextDocumentInput("1", "I work at Microsoft.")); textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { <START> System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); <END> final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), entity.getScore()); } } }); END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List }</code><technical_language>remove Model version log? codesnippet focus more valuable infor</technical_language>

Target:
public void recognizeBatchEntities() { List<TextDocumentInput> textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), new TextDocumentInput("1", "I work at Microsoft.")); textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), entity.getScore()); } } }); END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List }
Source:
<code>public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { for (int i = 0; i < callBinding.operands().size(); i++) { final SqlNode operand = callBinding.operands().get(i); if (literalOperands.contains(i)) { if (!SqlUtil.isLiteral(operand)) { return throwOrReturn( throwOnFailure, callBinding, cb -> cb.getValidator() .newValidationError( operand, Static.RESOURCE.argumentMustBeLiteral(callBinding.getOperator().getName()) ) ); } <START> if (!nullableOperands.contains(i) && SqlUtil.isNullLiteral(operand, true)) { <END> return throwOrReturn( throwOnFailure, callBinding, cb -> cb.getValidator().newValidationError(operand, Static.RESOURCE.nullIllegal()) ); } } final RelDataType operandType = callBinding.getValidator().deriveType(callBinding.getScope(), operand); final SqlTypeFamily expectedFamily = operandTypes.get(i); if (expectedFamily == SqlTypeFamily.ANY) { } else if (expectedFamily.getTypeNames().contains(operandType.getSqlTypeName())) { } else if (operandType.getSqlTypeName() == SqlTypeName.NULL) { if (!nullableOperands.contains(i)) { return throwOrReturn( throwOnFailure, callBinding, cb -> cb.getValidator().newValidationError(operand, Static.RESOURCE.nullIllegal()) ); } } else { return throwOrReturn( throwOnFailure, callBinding, SqlCallBinding::newValidationSignatureError ); } } return true; }</code><technical_language>sense for this null part of check consolidated else if (operandType.getSqlTypeName() == SqlTypeName.NULL) branch putting null check in if/else chain? I guess SqlUtil.isNullLiteral, is slightly more expensive of a check checking type name is null, is more correct casting a null is null</technical_language>

Target:
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { for (int i = 0; i < callBinding.operands().size(); i++) { final SqlNode operand = callBinding.operands().get(i); if (literalOperands.contains(i)) { if (!SqlUtil.isLiteral(operand)) { return throwOrReturn( throwOnFailure, callBinding, cb -> cb.getValidator() .newValidationError( operand, Static.RESOURCE.argumentMustBeLiteral(callBinding.getOperator().getName()) ) ); } } final RelDataType operandType = callBinding.getValidator().deriveType(callBinding.getScope(), operand); final SqlTypeFamily expectedFamily = operandTypes.get(i); if (expectedFamily == SqlTypeFamily.ANY) { } else if (expectedFamily.getTypeNames().contains(operandType.getSqlTypeName())) { } else if (operandType.getSqlTypeName() == SqlTypeName.NULL || SqlUtil.isNullLiteral(operand, true)) { if (!nullableOperands.contains(i)) { return throwOrReturn( throwOnFailure, callBinding, cb -> cb.getValidator().newValidationError(operand, Static.RESOURCE.nullIllegal()) ); } } else { return throwOrReturn( throwOnFailure, callBinding, SqlCallBinding::newValidationSignatureError ); } } return true; }
Source:
<code>private static boolean updateOption(VdcOption option) { Map<String, Object> values = _vdcOptionCache.get(option.getoption_name()); String optionVersion = option.getversion(); Object optionValue = getValue(option); boolean changed; if (values == null) { values = new HashMap<>(); <START> _vdcOptionCache.put(option.getoption_name(), values); <END> changed = true; } else { Object value = values.get(optionVersion); boolean newVersion = value == null; changed = newVersion || !value.equals(optionValue); } if (changed) { values.put(optionVersion, optionValue); } return changed; }</code><technical_language>lines 285-293 replaced a simple if ? if (!java.util.Objects.equals(values.get(optionVersion), optionValue)){ values.put(optionVersion, optionValue); return true; } return false; } assigning new map comparing new one. replace lines 285-297: return Objects.equals(values.put(optionVersion, optionValue), optionValue);</technical_language>

Target:
private static boolean updateOption(VdcOption option) { Map<String, Object> values = _vdcOptionCache.get(option.getoption_name()); String optionVersion = option.getversion(); Object newOptionValue = getValue(option); if (values == null) { values = new HashMap<>(); _vdcOptionCache.put(option.getoption_name(), values); values.put(optionVersion, newOptionValue); return true; } Object originalValue = values.get(optionVersion); values.put(optionVersion, newOptionValue); boolean newVersionSaved = originalValue == null; boolean changed = newVersionSaved || !originalValue.equals(newOptionValue); return changed; }
Source:
<code>public AgentImpl(String id, String name, String version, String description, List<String> dependencies, Map<String, String> properties, String script, Map<String, ? extends ServerConf2> servers) { this.id = id; this.name = name; this.version = version; this.description = description; <START> this.dependencies = dependencies != null ? dependencies : new ArrayList<>(); <END> this.properties = properties != null ? properties : new HashMap<>(); this.script = script; this.servers = servers != null ? servers : new HashMap<>(); }</code><technical_language>getters this check odd places if immutable Collection.emptyList()</technical_language>

Target:
public AgentImpl(String id, String name, String version, String description, List<String> dependencies, Map<String, String> properties, String script, Map<String, ? extends ServerConf2> servers) { this.id = id; this.name = name; this.version = version; this.description = description; this.dependencies = dependencies; this.properties = properties; this.script = script; this.servers = servers; }
Source:
<code>private void addCandidacy(final Map<Degree, SortedSet<SecondCycleIndividualCandidacyProcess>> result, final SecondCycleIndividualCandidacyProcess process) { for (Degree degree : process.getSelectedDegrees()) { SortedSet<SecondCycleIndividualCandidacyProcess> values = result.get(degree); if (values == null) { result.put(degree, values = new TreeSet<SecondCycleIndividualCandidacyProcess>( <START> SecondCycleIndividualCandidacyProcess.COMPARATOR_BY_CANDIDACY_PERSON)); <END> } values.add(process); } }</code><technical_language>Check if Map.computeIfAbsent</technical_language>

Target:
private void addCandidacy(final Map<Degree, SortedSet<SecondCycleIndividualCandidacyProcess>> result, final SecondCycleIndividualCandidacyProcess process) { for (Degree degree : process.getSelectedDegrees()) { SortedSet<SecondCycleIndividualCandidacyProcess> values = result.computeIfAbsent(degree, key -> (new TreeSet<SecondCycleIndividualCandidacyProcess>( SecondCycleIndividualCandidacyProcess.COMPARATOR_BY_CANDIDACY_PERSON))); values.add(process); } }
Source:
<code>public boolean isAssignableFrom(IType otherType) { final boolean result; if (!queryEnvironment.getEPackageProvider().isRegistered(type)) { result = false; } else if (getType() instanceof EClass && otherType.getType() instanceof EClass) { result = getType() == otherType.getType() <START> || ((EClass)otherType.getType()).getEAllSuperTypes().contains(getType()); <END> } else { final Class<?> ourClass = queryEnvironment.getEPackageProvider().getClass(getType()); final Class<?> otherClass; if (otherType instanceof EClassifierType) { otherClass = queryEnvironment.getEPackageProvider().getClass( ((EClassifierType)otherType).getType()); } else if (otherType instanceof IJavaType) { otherClass = ((IJavaType)otherType).getType(); } else { otherClass = null; } result = isAssignableFrom(ourClass, otherClass); } return result; }</code><technical_language>EPackageProvider.getAllSubTypes() faster check registration of EClasses</technical_language>

Target:
public boolean isAssignableFrom(IType otherType) { final boolean result; if (!queryEnvironment.getEPackageProvider().isRegistered(type)) { result = false; } else if (getType() instanceof EClass && otherType.getType() instanceof EClass) { result = getType() == otherType.getType() || queryEnvironment.getEPackageProvider().getAllSubTypes((EClass)getType()).contains( otherType.getType()); } else { final Class<?> ourClass = queryEnvironment.getEPackageProvider().getClass(getType()); final Class<?> otherClass; if (otherType instanceof EClassifierType) { otherClass = queryEnvironment.getEPackageProvider().getClass( ((EClassifierType)otherType).getType()); } else if (otherType instanceof IJavaType) { otherClass = ((IJavaType)otherType).getType(); } else { otherClass = null; } result = isAssignableFrom(ourClass, otherClass); } return result; }
Source:
<code>public File provisionInputFiles() { Map<String, String> wdlInputs = null; WdlBridge wdlBridge = new WdlBridge(); try { wdlInputs = wdlBridge.getInputFiles(localPrimaryDescriptorFile.getAbsolutePath()); } catch (Exception ex) { <START> exceptionMessage(ex, "Problem parsing WDL file: " + ex.getMessage(), API_ERROR); <END> } WDLFileProvisioning wdlFileProvisioning = new WDLFileProvisioning(abstractEntryClient.getConfigFile()); Gson gson = new Gson(); String jsonString = null; try { jsonString = abstractEntryClient.fileToJSON(selectedParameterFile); } catch (IOException ex) { errorMessage(ex.getMessage(), IO_ERROR); } Map<String, Object> inputJson = gson.fromJson(jsonString, HashMap.class); if (!isLocalEntry) { workingDirectory = tempLaunchDirectory.getAbsolutePath(); } else { workingDirectory = Paths.get(entry).toAbsolutePath().normalize().getParent().toString(); } System.out.println("Creating directories for run of Dockstore launcher in current working directory: " + workingDirectory); notificationsClient.sendMessage(NotificationsClient.PROVISION_INPUT, true); try { Map<String, Object> fileMap = wdlFileProvisioning.pullFiles(inputJson, wdlInputs); return new File(wdlFileProvisioning.createUpdatedInputsJson(inputJson, fileMap)); } catch (Exception e) { notificationsClient.sendMessage(NotificationsClient.PROVISION_INPUT, false); throw e; } }</code><technical_language>This exception is stay in for a long time, get a bit more specific (multi-catch you)</technical_language>

Target:
public File provisionInputFiles() { Map<String, String> wdlInputs = null; WdlBridge wdlBridge = new WdlBridge(); try { wdlInputs = wdlBridge.getInputFiles(localPrimaryDescriptorFile.getAbsolutePath()); } catch (WdlParser.SyntaxError ex) { exceptionMessage(ex, "Problem parsing WDL file: " + ex.getMessage(), API_ERROR); } WDLFileProvisioning wdlFileProvisioning = new WDLFileProvisioning(abstractEntryClient.getConfigFile()); Gson gson = new Gson(); String jsonString = null; try { jsonString = abstractEntryClient.fileToJSON(selectedParameterFile); } catch (IOException ex) { errorMessage(ex.getMessage(), IO_ERROR); } Map<String, Object> inputJson = gson.fromJson(jsonString, HashMap.class); if (!isLocalEntry) { workingDirectory = tempLaunchDirectory.getAbsolutePath(); } else { workingDirectory = Paths.get(entry).toAbsolutePath().normalize().getParent().toString(); } System.out.println("Creating directories for run of Dockstore launcher in current working directory: " + workingDirectory); notificationsClient.sendMessage(NotificationsClient.PROVISION_INPUT, true); try { Map<String, Object> fileMap = wdlFileProvisioning.pullFiles(inputJson, wdlInputs); return new File(wdlFileProvisioning.createUpdatedInputsJson(inputJson, fileMap)); } catch (Exception e) { notificationsClient.sendMessage(NotificationsClient.PROVISION_INPUT, false); throw e; } }
Source:
<code>public void subscribeToAllPollEventStopPollingAfterNSecondsTest() { Duration pollInterval = Duration.ofSeconds(1); Duration waitTime = Duration.ofSeconds(3); PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A")); PollResponse<Response> inProgress = new PollResponse<>(OperationStatus.IN_PROGRESS, new Response("Starting : Cert A")); when(pollOperation.apply(any())).thenReturn(Mono.just(inProgress), Mono.just(inProgress), Mono.just(success)); Poller<Response> poller = new Poller<>(pollInterval, pollOperation, null, ignored -> new PollResponse<Response>(OperationStatus.USER_CANCELLED, null)); StepVerifier.create(poller.getObserver()) .expectNext(inProgress) .then(() -> poller.setAutoPollingEnabled(false)) .expectNoEvent(waitTime) .then(() -> poller.cancelOperation()) <START> .verifyError(); <END> Assert.assertEquals(OperationStatus.IN_PROGRESS, poller.getStatus()); Assert.assertFalse(poller.isAutoPollingEnabled()); }</code><technical_language>This usecase ,user stop polling N second. I user is calling cancelOperation . remove call cancelOperation()</technical_language>

Target:
public void subscribeToAllPollEventStopPollingAfterNSecondsTest() { Duration pollInterval = Duration.ofSeconds(1); Duration waitTime = Duration.ofSeconds(3); PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A")); PollResponse<Response> inProgress = new PollResponse<>(OperationStatus.IN_PROGRESS, new Response("Starting : Cert A")); when(pollOperation.apply(any())).thenReturn(Mono.just(inProgress), Mono.just(inProgress), Mono.just(success)); Poller<Response> poller = new Poller<>(pollInterval, pollOperation, null, ignored -> new PollResponse<Response>(OperationStatus.USER_CANCELLED, null)); StepVerifier.create(poller.getObserver()) .expectNext(inProgress) .then(() -> poller.setAutoPollingEnabled(false)) .expectNoEvent(waitTime) .thenCancel() .verify(); Assert.assertEquals(OperationStatus.IN_PROGRESS, poller.getStatus()); Assert.assertFalse(poller.isAutoPollingEnabled()); }
Source:
<code>public Call<MwQueryResponse<QueryResult>> request(@NonNull Service service, @NonNull List<PageTitle> titles, @NonNull final Callback cb) { Call<MwQueryResponse<QueryResult>> call = service.request(TextUtils.join("|", titles), titles.size()); call.enqueue(new retrofit2.Callback<MwQueryResponse<QueryResult>>() { @Override public void onResponse(Call<MwQueryResponse<QueryResult>> call, Response<MwQueryResponse<QueryResult>> response) { if (response.isSuccessful()) { if (response.body().success()) { cb.success(call, response.body().query().pages()); } else if (response.body().hasError()) { cb.failure(call, new MwException(response.body().getError())); } else { cb.failure(call, new IOException("An unknown error occurred.")); } } else { cb.failure(call, RetrofitException.httpError(response, <START> cachedService.retrofit())); <END> } } @Override public void onFailure(Call<MwQueryResponse<QueryResult>> call, Throwable t) { cb.failure(call, t); } }); return call; }</code><technical_language>longer need pass this parameter. (build fails)</technical_language>

Target:
public Call<MwQueryResponse<QueryResult>> request(@NonNull Service service, @NonNull List<PageTitle> titles, @NonNull final Callback cb) { Call<MwQueryResponse<QueryResult>> call = service.request(TextUtils.join("|", titles), titles.size()); call.enqueue(new retrofit2.Callback<MwQueryResponse<QueryResult>>() { @Override public void onResponse(Call<MwQueryResponse<QueryResult>> call, Response<MwQueryResponse<QueryResult>> response) { if (response.isSuccessful()) { if (response.body().success()) { cb.success(call, response.body().query().pages()); } else if (response.body().hasError()) { cb.failure(call, new MwException(response.body().getError())); } else { cb.failure(call, new IOException("An unknown error occurred.")); } } else { cb.failure(call, RetrofitException.httpError(response)); } } @Override public void onFailure(Call<MwQueryResponse<QueryResult>> call, Throwable t) { cb.failure(call, t); } }); return call; }
Source:
<code>public void onVideoCallScreenUiReady() { LogUtil.v("VideoCallPresenter.onVideoCallScreenUiReady", ""); Assert.checkState(!isVideoCallScreenUiReady); if (!CompatUtils.isVideoCompatible()) { return; } mDeviceOrientation = InCallOrientationEventListener.getCurrentOrientation(); InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addDetailsListener(this); InCallPresenter.getInstance().addIncomingCallListener(this); InCallPresenter.getInstance().addOrientationListener(this); InCallPresenter.getInstance().addInCallEventListener(this); InCallPresenter.getInstance().getLocalVideoSurfaceTexture().setDelegate(new LocalDelegate()); InCallPresenter.getInstance().getRemoteVideoSurfaceTexture().setDelegate(new RemoteDelegate()); InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this); mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY; mCurrentCallState = DialerCall.State.INVALID; <START> isVideoCallScreenUiReady = true; <END> InCallPresenter.InCallState inCallState = InCallPresenter.getInstance().getInCallState(); onStateChange(inCallState, inCallState, CallList.getInstance()); }</code><technical_language>Revert this change</technical_language>

Target:
public void onVideoCallScreenUiReady() { LogUtil.v("VideoCallPresenter.onVideoCallScreenUiReady", ""); Assert.checkState(!isVideoCallScreenUiReady); if (!CompatUtils.isVideoCompatible()) { return; } mDeviceOrientation = InCallOrientationEventListener.getCurrentOrientation(); InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addDetailsListener(this); InCallPresenter.getInstance().addIncomingCallListener(this); InCallPresenter.getInstance().addOrientationListener(this); InCallPresenter.getInstance().addInCallEventListener(this); InCallPresenter.getInstance().getLocalVideoSurfaceTexture().setDelegate(new LocalDelegate()); InCallPresenter.getInstance().getRemoteVideoSurfaceTexture().setDelegate(new RemoteDelegate()); InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this); mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY; mCurrentCallState = DialerCall.State.INVALID; InCallPresenter.InCallState inCallState = InCallPresenter.getInstance().getInCallState(); onStateChange(inCallState, inCallState, CallList.getInstance()); isVideoCallScreenUiReady = true; }
Source:
<code>private boolean isInLayoutingMode(GraphicalEditPart graphicalEditPart) { View notationView = graphicalEditPart.getNotationView(); if (notationView != null) { Diagram diagram = notationView.getDiagram(); if (diagram != null) { EObject element = diagram.getElement(); <START> if (element instanceof DDiagram && ((DDiagram) element).isIsInLayoutingMode()) { return true; } <END> } } return false; }</code><technical_language>return element instanceof DDiagram && ((DDiagram) element).isInLayoutingMpode();</technical_language>

Target:
private boolean isInLayoutingMode(GraphicalEditPart graphicalEditPart) { View notationView = graphicalEditPart.getNotationView(); if (notationView != null) { Diagram diagram = notationView.getDiagram(); if (diagram != null) { EObject element = diagram.getElement(); return element instanceof DDiagram && ((DDiagram) element).isIsInLayoutingMode(); } } return false; }
Source:
<code>private Boolean checkCanSyncSolr(String studyStr, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); <START> if ("admin".equals(userId)) { <END> return true; } return authorizationManager.checkCanSyncSolr(studyStr, userId); }</code><technical_language>This if condition in authorizationManager.checkCanSyncSolr(studyStr, userId)</technical_language>

Target:
private Boolean checkCanSyncSolr(String studyStr, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); return authorizationManager.checkCanSyncSolr(studyStr, userId); }
Source:
<code>public Object getValueAt(int rowIndex, int columnIndex) { if(columnIndex == KEY_COLUMN) { return getKeyAt(rowIndex); } else if(columnIndex == PREVIEW_COLUMN){ return getPreviewAt(rowIndex); } else if(columnIndex == INTERVAL_COLUMN){ SortedSet<Double> ts = getMappedLegend().keySet(); Double d = getKeyAt(rowIndex); SortedSet<Double> tail = ts.tailSet(d); StringBuilder sb = new StringBuilder(); <START> sb.append("["); <END> if(Double.isInfinite(d)){ sb.append("-").append(Character.toString('\u221e')) ; }else { sb.append(d); } sb.append(";"); if(tail.size() == 1){ sb.append("+").append(Character.toString('\u221e')); } else { Iterator<Double> it = tail.iterator(); it.next(); sb.append(+it.next()); } sb.append("["); return sb.toString(); } throw new IndexOutOfBoundsException("We did not found a column at index "+columnIndex+" !"); }</code><technical_language>include negative infinity (at in contexts). notation "]-inf; b]" "[-inf; b]"</technical_language>

Target:
public Object getValueAt(int rowIndex, int columnIndex) { if(columnIndex == KEY_COLUMN) { return getKeyAt(rowIndex); } else if(columnIndex == PREVIEW_COLUMN){ return getPreviewAt(rowIndex); } else if(columnIndex == INTERVAL_COLUMN){ SortedSet<Double> ts = getMappedLegend().keySet(); Double d = getKeyAt(rowIndex); SortedSet<Double> tail = ts.tailSet(d); StringBuilder sb = new StringBuilder(); if(Double.isInfinite(d)){ sb.append("]"); sb.append("-").append(Character.toString('\u221e')) ; }else { sb.append("["); String numS = Math.abs(d) < 1.0 ? Double.toString(KeyCellRenderer.getRounded(d,DIGITS_NUMBER)): formatter.format(d); sb.append(numS); } sb.append("; "); if(tail.size() == 1){ sb.append("+").append(Character.toString('\u221e')); } else { Iterator<Double> it = tail.iterator(); it.next(); Double nd = it.next(); String numS = Math.abs(nd) < 1.0 ? Double.toString(KeyCellRenderer.getRounded(nd,DIGITS_NUMBER)): formatter.format(nd); sb.append(numS); } sb.append("["); return sb.toString(); } throw new IndexOutOfBoundsException("We did not found a column at index "+columnIndex+" !"); }
Source:
<code>public void testServices() { final List<Service> resultServices = this.kubernetesJobManagerSpecification.getAccompanyingResources() .stream() .filter(x -> x instanceof Service) .map(x -> (Service) x) .collect(Collectors.toList()); assertEquals(2, resultServices.size()); final List<Service> internalServiceCandidates = resultServices .stream() .filter(x -> x.getMetadata().getName().equals(KubernetesUtils.getInternalServiceName(CLUSTER_ID))) .collect(Collectors.toList()); assertEquals(1, internalServiceCandidates.size()); final List<Service> restServiceCandidates = resultServices .stream() .filter(x -> x.getMetadata().getName().equals(KubernetesUtils.getRestServiceName(CLUSTER_ID))) .collect(Collectors.toList()); assertEquals(1, restServiceCandidates.size()); final Service resultInternalService = internalServiceCandidates.get(0); assertEquals(2, resultInternalService.getMetadata().getLabels().size()); assertNull(resultInternalService.getSpec().getType()); <START> assertEquals("None", resultInternalService.getSpec().getClusterIP()); <END> assertEquals(2, resultInternalService.getSpec().getPorts().size()); assertEquals(5, resultInternalService.getSpec().getSelector().size()); final Service resultRestService = restServiceCandidates.get(0); assertEquals(2, resultRestService.getMetadata().getLabels().size()); assertEquals(resultRestService.getSpec().getType(), "LoadBalancer"); assertEquals(1, resultRestService.getSpec().getPorts().size()); assertEquals(5, resultRestService.getSpec().getSelector().size()); }</code><technical_language>update literal "None" here</technical_language>

Target:
public void testServices() { final List<Service> resultServices = this.kubernetesJobManagerSpecification.getAccompanyingResources() .stream() .filter(x -> x instanceof Service) .map(x -> (Service) x) .collect(Collectors.toList()); assertEquals(2, resultServices.size()); final List<Service> internalServiceCandidates = resultServices .stream() .filter(x -> x.getMetadata().getName().equals(KubernetesUtils.getInternalServiceName(CLUSTER_ID))) .collect(Collectors.toList()); assertEquals(1, internalServiceCandidates.size()); final List<Service> restServiceCandidates = resultServices .stream() .filter(x -> x.getMetadata().getName().equals(KubernetesUtils.getRestServiceName(CLUSTER_ID))) .collect(Collectors.toList()); assertEquals(1, restServiceCandidates.size()); final Service resultInternalService = internalServiceCandidates.get(0); assertEquals(2, resultInternalService.getMetadata().getLabels().size()); assertNull(resultInternalService.getSpec().getType()); assertEquals(Constants.HEADLESS_SERVICE_CLUSTER_IP, resultInternalService.getSpec().getClusterIP()); assertEquals(2, resultInternalService.getSpec().getPorts().size()); assertEquals(5, resultInternalService.getSpec().getSelector().size()); final Service resultRestService = restServiceCandidates.get(0); assertEquals(2, resultRestService.getMetadata().getLabels().size()); assertEquals(resultRestService.getSpec().getType(), "LoadBalancer"); assertEquals(1, resultRestService.getSpec().getPorts().size()); assertEquals(5, resultRestService.getSpec().getSelector().size()); }
Source:
<code>public AgentFilterService.InspectionReport inspect(@Valid final AgentClientMetadata agentClientMetadata) { final String minimumVersionString = this.agentFilterProperties.getMinimumVersion(); if (StringUtils.isNotBlank(minimumVersionString)) { final String agentVersionString = agentClientMetadata.getVersion().orElse(null); if (StringUtils.isNotBlank(agentVersionString)) { final ArtifactVersion minimumVersion = new DefaultArtifactVersion(minimumVersionString); final ArtifactVersion agentVersion = new DefaultArtifactVersion(agentVersionString); <START> System.out.println( <END> "" + minimumVersion + " vs " + agentVersion + " -> " + minimumVersion.compareTo(agentVersion) ); if (minimumVersion.compareTo(agentVersion) > 0) { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.REJECT, "Agent version " + agentVersionString + " is lower than minimum " + minimumVersionString ); } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.INCONCLUSIVE, "Agent version " + agentVersionString + " meets minimum " + minimumVersionString ); } } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.REJECT, "Agent version not set, minimum is: " + minimumVersionString ); } } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.INCONCLUSIVE, "Minimum version not set" ); } }</code><technical_language>this left in debugging/development</technical_language>

Target:
public AgentFilterService.InspectionReport inspect(@Valid final AgentClientMetadata agentClientMetadata) { final String minimumVersionString = this.agentFilterProperties.getMinimumVersion(); if (StringUtils.isNotBlank(minimumVersionString)) { final String agentVersionString = agentClientMetadata.getVersion().orElse(null); if (StringUtils.isNotBlank(agentVersionString)) { final ArtifactVersion minimumVersion = new DefaultArtifactVersion(minimumVersionString); final ArtifactVersion agentVersion = new DefaultArtifactVersion(agentVersionString); System.out.println( "" + minimumVersion + " vs " + agentVersion + " -> " + minimumVersion.compareTo(agentVersion) ); if (minimumVersion.compareTo(agentVersion) > 0) { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.REJECT, "Agent version " + agentVersionString + " is lower than minimum " + minimumVersionString ); } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.CONTINUE, "Agent version " + agentVersionString + " meets minimum " + minimumVersionString ); } } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.REJECT, "Agent version not set, minimum is: " + minimumVersionString ); } } else { return new AgentFilterService.InspectionReport( AgentFilterService.InspectionReport.InspectionDecision.CONTINUE, "Minimum version not set" ); } }
Source:
<code>private InputStream createFileInputStream(Path path) throws FileNotFoundException, IOException { final java.nio.file.Path nioPath = createJavaNioPath(path); final String name = path.toString(); if (profiler.isActive() && (profiler.isProfiling(ProfilerTask.VFS_READ) || profiler.isProfiling(ProfilerTask.VFS_OPEN))) { long startTime = Profiler.nanoTimeMaybe(); try { <START> return new ProfiledInputStream(Files.newInputStream(nioPath), name); <END> } finally { profiler.logSimpleTask(startTime, ProfilerTask.VFS_OPEN, name); } } else { return Files.newInputStream(nioPath, java.nio.file.StandardOpenOption.READ); } }</code><technical_language>Files.newInputStream revert it: <LINK_0>, /cc @meteorcloudy new FileInputStream</technical_language>

Target:
protected InputStream createFileInputStream(Path path) throws FileNotFoundException, IOException { return new FileInputStream(path.toString()); }
Source:
<code>public void disableOkButton() { <START> okButton.classList.add("disabled"); <END> }</code><technical_language>please extract "disabled" class constant, in future update correctly enable disable implementation</technical_language>

Target:
public void disableOkButton() { okButton.classList.add(DISABLED_CLASS); }
Source:
<code>public DownloadRequest into(ImageView imageView) { final DownloadRequestImpl downloadRequestImpl = new DownloadRequestImpl(downloadRequestBuilderStrategy, imageView); if (source instanceof String) { if (isCloudinaryPublicIdSource) { Url url = MediaManager.get().url().publicId(source).transformation(transformation); if (responsive != null) { responsive.generate(url, imageView, new ResponsiveUrl.Callback() { @Override public void onUrlReady(Url url) { setUrl(downloadRequestImpl, url.generate()); } }); } else { setUrl(downloadRequestImpl, url.generate()); } } else { setUrl(downloadRequestImpl, (String) source); } } else if (source instanceof Integer) { downloadRequestBuilderStrategy.load((Integer) source); <START> } else { <END> throw new IllegalStateException("load must be called before calling into!"); } if (placeholder != 0) { downloadRequestBuilderStrategy.placeholder(placeholder); } return downloadRequestImpl.start(); }</code><technical_language>Please separate exceptions - illegal argument exception in case source is a string/int either, illegal state exception if explicitly null. true currently, check is 100% accurate (since allow send in a string int), this change in a future commit easily miss this check unexpected error messages</technical_language>

Target:
public DownloadRequest into(ImageView imageView) { final DownloadRequestImpl downloadRequestImpl = new DownloadRequestImpl(downloadRequestBuilderStrategy, imageView); if (source == null) { throw new IllegalStateException("Source is null."); } if (source instanceof String) { if (isCloudinaryPublicIdSource) { Url url = MediaManager.get().url().publicId(source).transformation(transformation); if (responsive != null) { responsive.generate(url, imageView, new ResponsiveUrl.Callback() { @Override public void onUrlReady(Url url) { downloadRequestImpl.setSource(url.generate()); } }); } else { downloadRequestImpl.setSource(url.generate()); } } else { downloadRequestImpl.setSource(source); } } else if (source instanceof Integer) { downloadRequestImpl.setSource(source); } else { throw new IllegalArgumentException("Load source is not an instance of a correct type."); } if (placeholder != 0) { downloadRequestBuilderStrategy.placeholder(placeholder); } if (callback != null) { downloadRequestBuilderStrategy.callback(callback); } return downloadRequestImpl.start(); }
Source:
<code>public TimestampService createTimestampService(KeyValueService rawKvs, <START> Optional<TableReference> timestampTable) { <END> AtlasDbVersion.ensureVersionReported(); return PersistentTimestampService.create(JdbcTimestampBoundStore.create((JdbcKeyValueService) rawKvs)); }</code><technical_language>This default timestamp table (though atlasdb-jdbc AtlasDbConstants "_timestamp"!) suggest a Preconditions.checkArgument here, this a bit more dangerous InMemory in surprising consequences</technical_language>

Target:
public TimestampService createTimestampService(KeyValueService rawKvs, Optional<TableReference> timestampTable) { Preconditions.checkArgument(!timestampTable.isPresent() || timestampTable.get().equals(AtlasDbConstants.TIMESTAMP_TABLE), "***ERROR:This can cause severe data corruption.***\nUnexpected timestamp table found: " + timestampTable.map(TableReference::getQualifiedName).orElse("unknown table") + "\nThis can happen if you configure the timelock server to use JDBC KVS for timestamp" + " persistence, which is unsupported.\nWe recommend using the default paxos timestamp" + " persistence. However, if you are need to persist the timestamp service state in the" + " database, please specify a valid DbKvs config in the timestampBoundPersister block." + "\nNote that if the service has already been running, you will have to migrate the timestamp" + " table to Postgres/Oracle and rename it to %s.", AtlasDbConstants.TIMELOCK_TIMESTAMP_TABLE); AtlasDbVersion.ensureVersionReported(); return PersistentTimestampService.create(JdbcTimestampBoundStore.create((JdbcKeyValueService) rawKvs)); }
Source:
<code>public static void MakeUser() throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet res = null; try { conn = DriverManager.getConnection("jdbc:default:connection"); String sql = "INSERT INTO Users (Name, UserName) VALUES ('user1', 'fromproc')"; <START> stmt = conn.prepareStatement(sql); <END> stmt.execute(); } finally { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } }</code><technical_language>[try-with-resources](<LINK_0> syntax (both for statement connection)</technical_language>

Target:
public static void MakeUser() throws SQLException { try ( Connection conn = DriverManager.getConnection("jdbc:default:connection"); Statement stmt = conn.createStatement(); ) { String sql = "INSERT INTO Users (Name, UserName) VALUES ('user1', 'fromproc')"; stmt.execute(sql); } }
Source:
<code>private boolean removeMemoryVolumes(String memVols) { List<Guid> guids = GuidUtils.getGuidListFromString(memVols); if (guids.size() != NUM_OF_UUIDS_IN_MEMORT_STATE) { <START> log.warnFormat("Cannot remove memory volumes, invalid format: {0}", memVols); <END> return true; } Guid memoryImageRemovalTaskId = removeMemoryImage(guids); if (memoryImageRemovalTaskId == null) { return false; } Guid confImageRemovalTaskId = removeConfImage(guids); if (startPollingTasks) { if (!Guid.Empty.equals(memoryImageRemovalTaskId)) { AsyncTaskManager.getInstance().StartPollingTask(memoryImageRemovalTaskId); } if (confImageRemovalTaskId != null && !Guid.Empty.equals(confImageRemovalTaskId)) { AsyncTaskManager.getInstance().StartPollingTask(confImageRemovalTaskId); } } return confImageRemovalTaskId != null; }</code><technical_language>this method called empty string some flows get false logs</technical_language>

Target:
private boolean removeMemoryVolumes(String memVols) { List<Guid> guids = GuidUtils.getGuidListFromString(memVols); if (guids.size() != NUM_OF_UUIDS_IN_MEMORY_STATE) { log.warnFormat("Cannot remove memory volumes, invalid format: {0}", memVols); return true; } Guid memoryImageRemovalTaskId = removeMemoryImage(guids); if (memoryImageRemovalTaskId == null) { return false; } Guid confImageRemovalTaskId = removeConfImage(guids); if (startPollingTasks) { if (!Guid.Empty.equals(memoryImageRemovalTaskId)) { AsyncTaskManager.getInstance().StartPollingTask(memoryImageRemovalTaskId); } if (confImageRemovalTaskId != null && !Guid.Empty.equals(confImageRemovalTaskId)) { AsyncTaskManager.getInstance().StartPollingTask(confImageRemovalTaskId); } } return confImageRemovalTaskId != null; }
Source:
<code>public Iterable<String> getEdgeIds(Vertex otherVertex, Direction direction, String label, Authorizations authorizations) { <START> getFetchHints().validateHasEdgeFetchHints(direction); <END> return getEdgeIdsWithOtherVertexId(otherVertex.getId(), direction, labelToArrayOrNull(label), authorizations); }</code><technical_language>checking label</technical_language>

Target:
public Iterable<String> getEdgeIds(Vertex otherVertex, Direction direction, String label, Authorizations authorizations) { getFetchHints().validateHasEdgeFetchHints(direction, label); return getEdgeIdsWithOtherVertexId(otherVertex.getId(), direction, labelToArrayOrNull(label), authorizations); }
Source:
<code>private String getImageName() throws MojoExecutionException { List<ImageConfiguration> images = getResolvedImages(); if (saveName == null && saveAlias == null) { List<ImageConfiguration> buildImages = getImagesWithBuildConfig(images); <START> if (buildImages.isEmpty()) { <END> log.info("No images have a build configuration defined: save skipped"); return null; } if (buildImages.size() == 1) { return buildImages.get(0).getName(); } throw new MojoExecutionException("More than one image with build configuration is defined. Please specify the image with 'docker.name' or 'docker.alias'."); } if (saveName != null && saveAlias != null) { throw new MojoExecutionException("Cannot specify both name and alias."); } for (ImageConfiguration ic : images) { if (equalName(ic) || equalAlias(ic)) { return ic.getName(); } } throw new MojoExecutionException(saveName != null ? "Can not find image with name '" + saveName + "'" : "Can not find image with alias '"+ saveAlias + "'"); }</code><technical_language>move check start of executeInternal() ? E.g. obtain configuration add argument this method. clearer skip execution early if needed</technical_language>

Target:
private String getImageName() throws MojoExecutionException { List<ImageConfiguration> images = getResolvedImages(); if (saveName == null && saveAlias == null) { List<ImageConfiguration> buildImages = getImagesWithBuildConfig(images); if (buildImages.size() == 1) { return buildImages.get(0).getName(); } throw new MojoExecutionException("More than one image with build configuration is defined. Please specify the image with 'docker.name' or 'docker.alias'."); } if (saveName != null && saveAlias != null) { throw new MojoExecutionException("Cannot specify both name and alias."); } for (ImageConfiguration ic : images) { if (equalName(ic) || equalAlias(ic)) { return ic.getName(); } } throw new MojoExecutionException(saveName != null ? "Can not find image with name '" + saveName + "'" : "Can not find image with alias '"+ saveAlias + "'"); }
Source:
<code>private void notifyListeners() { for (LifecycleListener lifecycleListener : context.getLifecycleListeners()) { try { <START> lifecycleListener.onSessionReady(); <END> } catch (Throwable t) { Loggers.warnWithException( LOG, "[{}] Error while notifying of session ready", logPrefix, lifecycleListener, t); } } NodeStateListener nodeStateListener = context.getNodeStateListener(); if (nodeStateListener instanceof SessionAwareNodeStateListener) { ((SessionAwareNodeStateListener) nodeStateListener).onSessionReady(DefaultSession.this); } }</code><technical_language>pass session too</technical_language>

Target:
private void notifyListeners() { for (LifecycleListener lifecycleListener : context.getLifecycleListeners()) { try { lifecycleListener.onSessionReady(); } catch (Throwable t) { Loggers.warnWithException( LOG, "[{}] Error while notifying of session ready", logPrefix, lifecycleListener, t); } } context.getNodeStateListener().onSessionReady(DefaultSession.this); schemaListenerNotifier.onSessionReady(DefaultSession.this); context.getRequestTracker().onSessionReady(DefaultSession.this); }
Source:
<code><START> public String getLocation() { return bundle != null ? bundle.getLocation() : ""; } <END></code><technical_language>"" is correct alternative? null</technical_language>

Target:
public String getLocation() { return bundle.getLocation(); }
Source:
<code>private static void waitInitialized() { ListenableFuture<Void> future; synchronized (sInitDeinitLock) { <START> future = sInitDeinitFuture; <END> } if (!future.isDone()) { try { future.get(WAIT_INITIALIZED_TIMEOUT, TimeUnit.SECONDS); } catch (ExecutionException | InterruptedException | TimeoutException e) { e.printStackTrace(); } } }</code><technical_language>Currently init/deinit treated here. This wait for initialization. If deinitializing, this fail quickly</technical_language>

Target:
private static CameraX waitInitialized() { ListenableFuture<Void> future; CameraX cameraX; synchronized (sInitDeinitLock) { if (!sTargetInitialized) { return null; } future = sInitDeinitFuture; cameraX = sInstance; } if (!future.isDone()) { try { future.get(WAIT_INITIALIZED_TIMEOUT, TimeUnit.SECONDS); } catch (ExecutionException e) { throw new IllegalStateException(e); } catch (TimeoutException e) { throw new IllegalStateException(e); } catch (InterruptedException e) { throw new IllegalStateException(e); } } return cameraX; }