auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void reinit(TpeImageWidget iw, TpeImageInfo tii) { super.reinit(iw, tii); final TpeContext ctx = iw.getContext(); if (ctx.instrument().isEmpty()) return; final SPInstObsComp inst = ctx.instrument().get(); _feat = null; <START> if (inst instanceof InstNIRI) { <END> if (_niriFeat == null) _niriFeat = new NIRI_OIWFS_Feature(); _feat = _niriFeat; } else if (inst instanceof InstGmosNorth) { if (_gmosNFeat == null) _gmosNFeat = GmosNorthOIWFSFeature$.MODULE$; _feat = _gmosNFeat; } else if (inst instanceof InstGmosSouth || inst instanceof InstBHROS) { if (_gmosSFeat == null) _gmosSFeat = GmosSouthOIWFSFeature$.MODULE$; _feat = _gmosSFeat; } else if (inst instanceof InstGNIRS) { if (_gnirsFeat == null) _gnirsFeat = new GNIRS_OIWFS_Feature(); _feat = _gnirsFeat; } else if (inst instanceof InstNIFS) { if (_nifsFeat == null) _nifsFeat = new NIFS_OIWFS_Feature(); _feat = _nifsFeat; } else if (inst instanceof Flamingos2) { if (_flamingos2Feat == null) _flamingos2Feat = Flamingos2OIWFSFeature$.MODULE$; _feat = _flamingos2Feat; } if (_feat != null) { _feat.reinit(iw, tii); } }</code><technical_language>replace this a scala wrapper avoid calls XXX$.MODULE$, this is priority</technical_language>

Target:
public void reinit(TpeImageWidget iw, TpeImageInfo tii) { super.reinit(iw, tii); final TpeContext ctx = iw.getContext(); if (ctx.instrument().isEmpty()) return; final SPInstObsComp inst = ctx.instrument().get(); _feat = null; if (inst instanceof InstNIRI) { if (_niriFeat == null) _niriFeat = new NIRI_OIWFS_Feature(); _feat = _niriFeat; } else if (inst instanceof InstGmosNorth) _feat = GmosNorthOIWFSFeature.instance(); else if (inst instanceof InstGmosSouth || inst instanceof InstBHROS) _feat = GmosSouthOIWFSFeature.instance(); else if (inst instanceof InstGNIRS) { if (_gnirsFeat == null) _gnirsFeat = new GNIRS_OIWFS_Feature(); _feat = _gnirsFeat; } else if (inst instanceof InstNIFS) { if (_nifsFeat == null) _nifsFeat = new NIFS_OIWFS_Feature(); _feat = _nifsFeat; } else if (inst instanceof Flamingos2) _feat = Flamingos2OIWFSFeature.instance(); if (_feat != null) _feat.reinit(iw, tii); }
Source:
<code>public static String encryptOrder(LgoKey lgoKey, LgoPlaceOrder lgoPlaceOrder) { try { String pub = lgoKey.getValue(); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] keyBytes = Base64.getDecoder().decode(pub.getBytes(StandardCharsets.UTF_8)); X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(spec); Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] cipherData = cipher.doFinal(lgoPlaceOrder.toPayload().getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(cipherData); <START> } catch (Exception e) { <END> throw new ExchangeException("Error encrypting order", e); } }</code><technical_language>more specific exceptions here? potential NPE OutOfMemoryExceptions for eq. wrapped ExchangeException</technical_language>

Target:
public static String encryptOrder(LgoKey lgoKey, LgoPlaceOrder lgoPlaceOrder) { try { String pub = lgoKey.getValue(); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] keyBytes = Base64.getDecoder().decode(pub.getBytes(StandardCharsets.UTF_8)); X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(spec); Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] cipherData = cipher.doFinal(lgoPlaceOrder.toPayload().getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(cipherData); } catch (NoSuchAlgorithmException e) { throw new ExchangeException("Error encrypting order: algorithm instance not available", e); } catch (NoSuchPaddingException e) { throw new ExchangeException("Error encrypting order: padding instance not available", e); } catch (IllegalBlockSizeException | BadPaddingException | InvalidKeySpecException | InvalidKeyException e) { throw new ExchangeException("Error encrypting order: provided data invalid", e); } }
Source:
<code>public void setEnableSmallFileFeatures(final boolean on) { enableSmallFileFeatures = on; if (enableSmallFileFeatures) { syntaxHighlighting.setValue(getValue().isSyntaxHighlighting()); } else { syntaxHighlighting.setValue(false); } NodeList<OptionElement> options = context.getElement().<SelectElement>cast().getOptions(); <START> for (int i = 0; i < options.getLength(); i++) { <END> OptionElement currOption = options.getItem(i); if (Short.parseShort(currOption.getValue()) == AccountDiffPreference.WHOLE_FILE_CONTEXT) { if (enableSmallFileFeatures) { currOption.setDisabled(false); } else { currOption.setDisabled(true); if (context.getSelectedIndex() > -1 && AccountDiffPreference.CONTEXT_CHOICES[context.getSelectedIndex()] == AccountDiffPreference.WHOLE_FILE_CONTEXT) { for (int j = 0; i < AccountDiffPreference.CONTEXT_CHOICES.length; j++) { if (AccountDiffPreference.CONTEXT_CHOICES[j] == PatchScreen.LARGE_FILE_CONTEXT) { context.setSelectedIndex(j); break; } } } } break; } } toggleEnabledStatus(save.isEnabled()); }</code><technical_language>This loop wastes time, if rely fact WHOLE_FILE_CONTEXT is item in array ListBox (and a note that)</technical_language>

Target:
public void setEnableSmallFileFeatures(final boolean on) { enableSmallFileFeatures = on; if (enableSmallFileFeatures) { syntaxHighlighting.setValue(getValue().isSyntaxHighlighting()); } else { syntaxHighlighting.setValue(false); } NodeList<OptionElement> options = context.getElement().<SelectElement>cast().getOptions(); int lastIndex = options.getLength() - 1; OptionElement currOption = options.getItem(lastIndex); if (enableSmallFileFeatures) { currOption.setDisabled(false); } else { currOption.setDisabled(true); if (context.getSelectedIndex() == lastIndex) { context.setSelectedIndex(lastIndex - 1); } } toggleEnabledStatus(save.isEnabled()); }
Source:
<code>public ChainrBuilder loader( ChainrInstantiator loader ) { <START> this.chainrInstantiator = loader; <END> return this; }</code><technical_language>need a null check here</technical_language>

Target:
public ChainrBuilder loader( ChainrInstantiator loader ) { if ( loader == null ) { throw new RuntimeException( "ChainrBuilder requires a non-null laoder." ); } this.chainrInstantiator = loader; return this; }
Source:
<code>public boolean setText (String html, boolean trusted) { byte[] bytes = (html + '\0').getBytes (StandardCharsets.UTF_8); boolean blankLoading = htmlBytes != null; htmlBytes = bytes; untrustedText = !trusted; if (WEBKIT2) { byte[] uriBytes; if <START> (url != null) { <END> uriBytes = Converter.wcsToMbcs (url, true); } else if (untrustedText) { uriBytes = Converter.wcsToMbcs (ABOUT_BLANK, true); } else { uriBytes = Converter.wcsToMbcs (URI_FILEROOT, true); } WebKitGTK.webkit_web_view_load_html (webView, htmlBytes, uriBytes); } else { if (blankLoading) return true; byte[] uriBytes = Converter.wcsToMbcs (ABOUT_BLANK, true); WebKitGTK.webkit_web_view_load_uri (webView, uriBytes); } return true; }</code><technical_language>Webkit.java a lot of globals, code difficult read. I suggest instead 'WebKitGTK.webkit_web_view_load_html (webView, htmlBytes, uriBytes);' directly? Feel free newer Converter.java:javaStringToCString(String) method, takes a java string converts utf-8 null terminated string need for webkit. (webkit a lot of code this manually). If is absolute this method, add paramaters create a another signature paramaters calling that</technical_language>

Target:
public boolean setText (String html, boolean trusted) { byte[] bytes = (html + '\0').getBytes (StandardCharsets.UTF_8); boolean blankLoading = htmlBytes != null; htmlBytes = bytes; untrustedText = !trusted; if (WEBKIT2) { byte[] uriBytes; if (untrustedText) { uriBytes = Converter.wcsToMbcs (ABOUT_BLANK, true); } else { uriBytes = Converter.wcsToMbcs (URI_FILEROOT, true); } WebKitGTK.webkit_web_view_load_html (webView, htmlBytes, uriBytes); } else { if (blankLoading) return true; byte[] uriBytes = Converter.wcsToMbcs (ABOUT_BLANK, true); WebKitGTK.webkit_web_view_load_uri (webView, uriBytes); } return true; }
Source:
<code>private void processFeatures() { for (Feature feature : features) { List<ScenarioTag> scenarioList = new ArrayList<>(); Element[] scenarios = feature.getElements(); numberOfScenarios = getNumberOfScenarios(scenarios); int count = 1; <START> if (featureNamesCount.containsKey(feature.getFileName())) { <END> count = featureNamesCount.get(feature.getFileName()); count++; } featureNamesCount.put(feature.getFileName(),count); feature.setFileName(count); if (feature.hasTags()) { for (Element e : feature.getElements()) { if (!e.isBackground()) { scenarioList.add(new ScenarioTag(e, feature.getFileName())); } } addToTagMapByFeature(feature.getTags(), scenarioList); } for (Element scenario : scenarios) { if (!scenario.isBackground()) { totalBackgroundSteps.incrementFor(scenario.getStatus()); } else { setBackgroundInfo(scenario); } if (scenario.hasTags()) { addScenarioUnlessExists(scenarioList, new ScenarioTag(scenario, feature.getFileName())); addToTagMap(scenario.getTags(), scenarioList); } adjustStepsForScenario(scenario); } } }</code><technical_language>Feature is identified unique ID, file name</technical_language>

Target:
private void processFeatures() { for (Feature feature : features) { List<ScenarioTag> scenarioList = new ArrayList<>(); Element[] scenarios = feature.getElements(); numberOfScenarios = getNumberOfScenarios(scenarios); int count = 1; if (featureIdsCount.containsKey(feature.getId())) { count = featureIdsCount.get(feature.getId()); count++; } featureIdsCount.put(feature.getId(), count); feature.setFileName(count); if (feature.hasTags()) { for (Element e : feature.getElements()) { if (!e.isBackground()) { scenarioList.add(new ScenarioTag(e, feature.getFileName())); } } addToTagMapByFeature(feature.getTags(), scenarioList); } for (Element scenario : scenarios) { if (!scenario.isBackground()) { totalBackgroundSteps.incrementFor(scenario.getStatus()); } else { setBackgroundInfo(scenario); } if (scenario.hasTags()) { addScenarioUnlessExists(scenarioList, new ScenarioTag(scenario, feature.getFileName())); addToTagMap(scenario.getTags(), scenarioList); } adjustStepsForScenario(scenario); } } }
Source:
<code>public void execute() throws Exception { VirtualObject file = process.require(fileParameter); try (InputStream in = storage.getData(file)) { if (!canHandleFileExtension(file.getFileExtension()) && "zip".equalsIgnoreCase(file.getFileExtension())) { executeForZippedFile(in); return; } <START> if (!canHandleFileExtension(file.getFileExtension())) { <END> throw Exceptions.createHandled().withNLSKey("FileImportJob.fileNotSupported").handle(); } executeForStream(file.getFilename(), in); } }</code><technical_language>combine if loading data (above storage.getData())</technical_language>

Target:
public void execute() throws Exception { VirtualObject file = process.require(fileParameter); if (!canHandleFileExtension(file.getFileExtension())) { if ("zip".equalsIgnoreCase(file.getFileExtension())) { try (InputStream in = storage.getData(file)) { executeForZippedFile(in); } return; } throw Exceptions.createHandled().withNLSKey("FileImportJob.fileNotSupported").handle(); } try (InputStream in = storage.getData(file)) { executeForStream(file.getFilename(), in); } }
Source:
<code>public void testColumnScannerStream() { Set<ColumnValue> colsVal = new HashSet<>(); Set<ColumnValue> empty = new HashSet<>(); Bytes row = Bytes.of("123"); colsVal.add(new ColumnValue(new Column("f1", "q1"), Bytes.of("v1"))); colsVal.add(new ColumnValue(new Column("f2", "q3"), Bytes.of("v2"))); colsVal.add(new ColumnValue(new Column("f1", "q1"), Bytes.of("v3"))); colsVal.add(new ColumnValue(new Column("f1", "q2"), Bytes.of("v4"))); colsVal.add(new ColumnValue(new Column("f2", "q5"), Bytes.of("v5"))); <START> ColumnScanner colScanStream = new ColumnScannerImpl(row, colsVal); <END> colsVal.stream().filter(cv -> cv.getColumn().getsFamily().equals("f2")) .collect(Collectors.toSet()); colScanStream.stream().filter(cv -> cv.getColumn().getsFamily().equals("f2")) .collect(Collectors.toSet()); Assert.assertNotEquals(empty, colScanStream.stream().collect(Collectors.toSet())); Assert.assertEquals(colsVal, colScanStream.stream().collect(Collectors.toSet())); Assert.assertEquals(colsVal.size(), colScanStream.stream().count()); }</code><technical_language>Personally I Stream in this var name. call scanner of colScanner</technical_language>

Target:
public void testColumnScannerStream() { Set<ColumnValue> colsVal = new HashSet<>(); Set<ColumnValue> empty = new HashSet<>(); Bytes row = Bytes.of("123"); colsVal.add(new ColumnValue(new Column("f1", "q1"), Bytes.of("v1"))); colsVal.add(new ColumnValue(new Column("f2", "q3"), Bytes.of("v2"))); colsVal.add(new ColumnValue(new Column("f1", "q1"), Bytes.of("v3"))); colsVal.add(new ColumnValue(new Column("f1", "q2"), Bytes.of("v4"))); colsVal.add(new ColumnValue(new Column("f2", "q5"), Bytes.of("v5"))); ColumnScanner colScanner = new ColumnScannerImpl(row, colsVal); Set<ColumnValue> expected = colsVal.stream().filter(cv -> cv.getColumn().getsFamily().equals("f2")) .collect(Collectors.toSet()); Set<ColumnValue> colSubSet = colScanner.stream().filter(cv -> cv.getColumn().getsFamily().equals("f2")) .collect(Collectors.toSet()); Assert.assertNotEquals(empty, colSubSet); Assert.assertNotEquals(empty, colScanner.stream().collect(Collectors.toSet())); Assert.assertEquals(colsVal, colScanner.stream().collect(Collectors.toSet())); Assert.assertEquals(expected, colSubSet); }
Source:
<code>public static Intent createChooserIntent(Intent targetIntent, CharSequence chooserTitle, Context context, String packageNameBlacklistRegex) { List<LabeledIntent> intents = queryIntents(context, targetIntent, packageNameBlacklistRegex); if (intents.isEmpty()) { return null; } Intent bestIntent = intents.remove(0); <START> return Intent.createChooser(targetIntent, chooserTitle) <END> .putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray()); }</code><technical_language>Is this correct? bestIntent is longer in picker options</technical_language>

Target:
public static Intent createChooserIntent(Intent targetIntent, CharSequence chooserTitle, Context context, String packageNameBlacklistRegex) { List<LabeledIntent> intents = queryIntents(context, targetIntent, packageNameBlacklistRegex); if (intents.isEmpty()) { return null; } Intent bestIntent = intents.remove(0); return Intent.createChooser(bestIntent, chooserTitle) .putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray(new Parcelable[0])); }
Source:
<code>private void averageWaitingTime() { fWriter.println("----- Average waiting time with 3 requests -----"); for (int i = 0; i < NUM_LOOPS; i++) { ForegroundRequest foreground1 = new ForegroundRequest(TmfTimeRange.ETERNITY); ForegroundRequest foreground2 = new ForegroundRequest(TmfTimeRange.ETERNITY); BackgroundRequest background1 = new BackgroundRequest(TmfTimeRange.ETERNITY); fTrace.sendRequest(background1); fTrace.sendRequest(foreground1); fTrace.sendRequest(foreground2); try { foreground1.waitForCompletion(); foreground2.waitForCompletion(); background1.waitForCompletion(); } catch (InterruptedException e) { e.printStackTrace(); } averageWaitingBackground += background1.getAverageWaitingTime(); averageWaitingForeground1 += foreground1.getAverageWaitingTime(); averageWaitingForeground2 += foreground2.getAverageWaitingTime(); } fWriter.println("-- Background --"); <START> fWriter.println((averageWaitingBackground / NUM_LOOPS) / 1000000 + " ms"); END> fWriter.println("-- First foreground --"); fWriter.println((averageWaitingForeground1 / NUM_LOOPS) / 1000000 + " ms"); fWriter.println("-- Second foreground --"); fWriter.println((averageWaitingForeground2 / NUM_LOOPS) / 1000000 + " ms"); }</code><technical_language>a static final define for 1000000, MILLISECONDS_IN_SECONDS. Juuuust safe ;)</technical_language>

Target:
private void averageWaitingTime() { System.out.println("----- Average waiting time with 3 requests -----"); for (int i = 0; i < NUM_LOOPS; i++) { ForegroundRequest foreground1 = new ForegroundRequest(TmfTimeRange.ETERNITY); ForegroundRequest foreground2 = new ForegroundRequest(TmfTimeRange.ETERNITY); BackgroundRequest background1 = new BackgroundRequest(TmfTimeRange.ETERNITY); fTrace.sendRequest(background1); fTrace.sendRequest(foreground1); fTrace.sendRequest(foreground2); try { foreground1.waitForCompletion(); foreground2.waitForCompletion(); background1.waitForCompletion(); } catch (InterruptedException e) { e.printStackTrace(); } averageWaitingBackground += background1.getAverageWaitingTime(); averageWaitingForeground1 += foreground1.getAverageWaitingTime(); averageWaitingForeground2 += foreground2.getAverageWaitingTime(); } System.out.println("-- Background --"); System.out.println((averageWaitingBackground / NUM_LOOPS) / NANOSECONDS_IN_MILLISECONDS + " ms"); System.out.println("-- First foreground --"); System.out.println((averageWaitingForeground1 / NUM_LOOPS) / NANOSECONDS_IN_MILLISECONDS + " ms"); System.out.println("-- Second foreground --"); System.out.println((averageWaitingForeground2 / NUM_LOOPS) / NANOSECONDS_IN_MILLISECONDS + " ms"); }
Source:
<code>private void sendVolume(String host, Command command) { logger.debug("Sending volume to host " + host + " for command " + command.toString()); volumeConfig conf = getTVVolume(host); String url = "http://" + host + "/1/audio/volume"; StringBuilder content = new StringBuilder(); int newvalue = conf.volume; if (command instanceof DecimalType) { logger.debug("Setting volume to decimal type"); newvalue = ((DecimalType)command).intValue(); } else if (command instanceof IncreaseDecreaseType) { if ((IncreaseDecreaseType)command == IncreaseDecreaseType.INCREASE) { logger.debug("Increased volume"); newvalue ++; } else { logger.debug("Decreased volume"); newvalue --; } } else { logger.warn("Unitl now only DecimalType and IncreaseDecreaseType commands are supported vor volume command"); return; } newvalue = Math.min(newvalue, conf.max); newvalue = Math.max(newvalue, conf.min); content.append("{\"muted\":\"" + conf.mute + "\", \"current\":\""+newvalue+"\"}"); logger.trace(content.toString()); String retval = HttpUtil.executeUrl("POST", url, IOUtils.toInputStream(content.toString()), CONTENT_TYPE_JSON, 1000); if (retval == null) { logger.warn("Sending Volume failed"); } else { logger.debug("Sending Volume successfull"); <START> } <END> }</code><technical_language>handle failure of executeUrl (logging return value) leave is (as in other places)</technical_language>

Target:
private void sendVolume(String host, Command command) { logger.debug("Sending volume to host for command {}", host,command.toString()); volumeConfig conf = getTVVolume(host); String url = "http://" + host + "/1/audio/volume"; int newvalue = conf.volume; if (command instanceof DecimalType) { logger.debug("Setting volume to decimal type"); newvalue = ((DecimalType)command).intValue(); } else if (command instanceof IncreaseDecreaseType) { if ((IncreaseDecreaseType)command == IncreaseDecreaseType.INCREASE) { logger.debug("Increased volume"); newvalue ++; } else { logger.debug("Decreased volume"); newvalue --; } } else { logger.warn("Unitl now only DecimalType and IncreaseDecreaseType commands are supported vor volume command"); return; } newvalue = Math.min(newvalue, conf.max); newvalue = Math.max(newvalue, conf.min); String content = "{\"muted\":\"" + conf.mute + "\", \"current\":\""+newvalue+"\"}"; logger.trace(content); HttpUtil.executeUrl("POST", url, IOUtils.toInputStream(content), CONTENT_TYPE_JSON, 1000); }
Source:
<code>public void logReport(String userId, String email, String siteId, String type, String title, String content) throws SQLException { Connection conn = null; try { conn = sqlService.borrowConnection(); sqlService.dbWrite(conn, insertReportSql, new String[] {userId, email, siteId, type, title, content}); } catch (SQLException sqlException){ logger.error("Failed to insert feedback report. Caught sql exception while generating report. '" + FeedbackEntityProvider.DB_ERROR + "' will be returned to the client.", sqlException); if (conn != null) { sqlService.returnConnection(conn); } <START> throw new SQLException(); <END> } }</code><technical_language>re-throw existing sqlException</technical_language>

Target:
public void logReport(String userId, String email, String siteId, String type, String title, String content) throws SQLException { Connection conn = null; try { conn = sqlService.borrowConnection(); sqlService.dbWrite(conn, insertReportSql, new String[] {userId, email, siteId, type, title, content}); } catch (SQLException sqlException){ logger.error("Failed to insert feedback report. Caught sql exception while generating report. '" + DB_ERROR + "' will be returned to the client.", sqlException); throw sqlException; } finally { if (conn != null) { sqlService.returnConnection(conn); } } }
Source:
<code>public void onResume() { super.onResume(); <START> boolean shouldBeHere = (CommCareApplication._().getVisibleAppRecords().size() == 1 && <END> CommCareApplication._().getReadyAppRecords().size() == 0); if (!fromManager && !shouldBeHere) { Intent i = new Intent(this, CommCareHomeActivity.class); this.startActivity(i); } }</code><technical_language>roll "!fromManager" call here, abstractly part of notion of in place, if fromManager is true skip DbQuery here</technical_language>

Target:
public void onResume() { super.onResume(); boolean shouldBeHere = fromManager || CommCareApplication._().shouldSeeMMVerification(); if (!shouldBeHere) { Intent i = new Intent(this, CommCareHomeActivity.class); startActivity(i); } }
Source:
<code>public void killContainer(String containerId) throws DockerAccessException { try { String url = urlBuilder.killContainer(containerId); <START> log.verbose(Logger.LogVerboseCategory.API,"POSTing %s", url); <END> delegate.post(url, HTTP_NO_CONTENT, HTTP_NOT_MODIFIED); } catch (IOException ie) { throw new DockerAccessException(ie, "Unable to kill container id [%s]", containerId); } }</code><technical_language>suggestion log.verbose(Logger.LogVerboseCategory.API,"POST %s", url);</technical_language>

Target:
public void killContainer(String containerId) throws DockerAccessException { try { String url = urlBuilder.killContainer(containerId); log.verbose(Logger.LogVerboseCategory.API,"POST %s", url); delegate.post(url, HTTP_NO_CONTENT, HTTP_NOT_MODIFIED); } catch (IOException ie) { throw new DockerAccessException(ie, "Unable to kill container id [%s]", containerId); } }
Source:
<code>public void send(final Sender sender) throws IOException { final byte[] payload = this.payload.load(); sender.send(payload); <START> } <END></code><technical_language>Objects.requireNonNull(sender)</technical_language>

Target:
public void send(final Sender sender) throws IOException { Objects.requireNonNull(sender); final byte[] payload = this.payload.load(); sender.send(payload); }
Source:
<code>private Collection<JM> getJoinOutput(K key, Object value, M message) { <START> R record = Optional.ofNullable(value) <END> .map(val -> (R) KV.of(key, val)) .orElse(null); JM output = joinOpSpec.getJoinFn().apply(message, record); return output != null ? Collections.singletonList(output) : Collections.emptyList(); }</code><technical_language>I user join function invoked more this change. simpler: R record = == null ? null : (R) KV.of(key, value);</technical_language>

Target:
private Collection<JM> getJoinOutput(K key, Object value, M message) { R record = value == null ? null : (R) KV.of(key, value); JM output = joinOpSpec.getJoinFn().apply(message, record); return output != null ? Collections.singletonList(output) : Collections.emptyList(); }
Source:
<code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FolderPickerActivity.DIRECTORY_REQUEST_CODE && resultCode == RESULT_OK) { Folder selectedFolder = (Folder) mFoldersSpinner.getSelectedItem(); String folderDirectory = selectedFolder.path; if (!folderDirectory.endsWith("/")) { folderDirectory += "/"; } <START> String subDirectory = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY) + "/"; <END> subDirectory = (subDirectory).replace(folderDirectory.substring(0, folderDirectory.length()), ""); mSubDirectoryTextView.setText(subDirectory); PreferenceManager.getDefaultSharedPreferences(this) .edit().putString(PREF_FOLDER_SAVED_SUBDIRECTORY+selectedFolder.id, subDirectory) .apply(); } }</code><technical_language>Instead of messing path formatting manually, [file.toURI().normalize().getPath()](<LINK_0> get properly formatted path. put in a method in Util call FolderPickerActivity:200 ShareActivity:361</technical_language>

Target:
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FolderPickerActivity.DIRECTORY_REQUEST_CODE && resultCode == RESULT_OK) { Folder selectedFolder = (Folder) mFoldersSpinner.getSelectedItem(); String folderDirectory = Util.formatPath(selectedFolder.path); String subDirectory = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY); subDirectory = subDirectory.replace(folderDirectory, ""); mSubDirectoryTextView.setText(subDirectory); PreferenceManager.getDefaultSharedPreferences(this) .edit().putString(PREF_FOLDER_SAVED_SUBDIRECTORY + selectedFolder.id, subDirectory) .apply(); } }
Source:
<code>mergeJoin(final Enumerable<TSource> outer, final Enumerable<TInner> inner, final Function1<TSource, TKey> outerKeySelector, final Function1<TInner, TKey> innerKeySelector, final Function2<TSource, TInner, TResult> resultSelector, boolean generateNullsOnLeft, boolean generateNullsOnRight) { if (generateNullsOnLeft) { <START> throw new UnsupportedOperationException("not implemented"); <END> } if (generateNullsOnRight) { throw new UnsupportedOperationException("not implemented"); } return new AbstractEnumerable<TResult>() { public Enumerator<TResult> enumerator() { return new MergeJoinEnumerator<>(outer.enumerator(), inner.enumerator(), outerKeySelector, innerKeySelector, resultSelector); } }; }</code><technical_language>Please meaningful exception messages. Do want UnsupportedOperationException("not implemented") in production logs? I bet</technical_language>

Target:
mergeJoin(final Enumerable<TSource> outer, final Enumerable<TInner> inner, final Function1<TSource, TKey> outerKeySelector, final Function1<TInner, TKey> innerKeySelector, final Function2<TSource, TInner, TResult> resultSelector, boolean generateNullsOnLeft, boolean generateNullsOnRight) { if (generateNullsOnLeft) { throw new UnsupportedOperationException( "not implemented, mergeJoin with generateNullsOnLeft"); } if (generateNullsOnRight) { throw new UnsupportedOperationException( "not implemented, mergeJoin with generateNullsOnRight"); } return new AbstractEnumerable<TResult>() { public Enumerator<TResult> enumerator() { return new MergeJoinEnumerator<>(outer.enumerator(), inner.enumerator(), outerKeySelector, innerKeySelector, resultSelector); } }; }
Source:
<code>private void assertHeroAndMouseCoords(Vector2 mouseCoords, Vector2 heroCoords) { <START> if(Double.isNaN(mouseCoords.x) || Double.isNaN(mouseCoords.y)) { <END> System.err.println("Screen size: " + Gdx.graphics.getWidth() + " " + Gdx.graphics.getHeight()); throw new RuntimeException("Mouse coordinates are not valid: " + mouseCoords.x + " " + mouseCoords.y); } if(Double.isNaN(heroCoords.x) || Double.isNaN(heroCoords.y)) { System.err.println("Screen size: " + Gdx.graphics.getWidth() + " " + Gdx.graphics.getHeight()); throw new RuntimeException("Hero coordinates are not valid: " + heroCoords.x + " " + heroCoords.y); } }</code><technical_language>suggestion if (Double.isNaN(mouseCoords.x) || Double.isNaN(mouseCoords.y)) {</technical_language>

Target:
private void assertHeroAndMouseCoords(Vector2 mouseCoords, Vector2 heroCoords) { if (Double.isNaN(mouseCoords.x) || Double.isNaN(mouseCoords.y)) { throw new RuntimeException("Mouse coordinates are not valid: " + mouseCoords.x + " " + mouseCoords.y); } if (Double.isNaN(heroCoords.x) || Double.isNaN(heroCoords.y)) { throw new RuntimeException("Hero coordinates are not valid: " + heroCoords.x + " " + heroCoords.y); } }
Source:
<code>public Set<String> getAllGenres(final Record record) { Set<String> freeFormGenres = new HashSet<String>(); Set<String> genres = new HashSet<String>(); Set<String> allGenres = new HashSet<String>(); freeFormGenres = getFreeFormGenre(record, "[\\\\,;:]", "([\\p{L}\\p{N}]{4}|\\.*?[\\s)]|[..{2,}]|[AMUaw][adir][cirt])"); genres = getGenres(record); allGenres.addAll(freeFormGenres); <START> allGenres.addAll(genres); <END> return allGenres; }</code><technical_language>do of: java Set<String> allGenres = getGenres(record); allGenres.addAll(getFreeFormGenre(record, "[\\\\,;:]", "([\\p{L}\\p{N}]{4}|\\.*?[\\s)]|[..{2,}]|[AMUaw][adir][cirt])");</technical_language>

Target:
public Set<String> getAllGenres(final Record record) { Set<String> allGenres = getGenres(record); allGenres.addAll(getFreeFormGenre(record)); return allGenres; }
Source:
<code>public boolean findContactForAcquisition(IAcquisitionWork acquisition, Person person, PlanetarySystem system) { <START> if (null == person || !canAcquireParts(person)) { <END> return false; } DateTime currentDate = Utilities.getDateTimeDay(getCalendar()); TargetRoll target = getTargetForAcquisition(acquisition, person, false); target = system.getPrimaryPlanet().getAcquisitionMods(target, getDate(), getCampaignOptions(), getFaction(), acquisition.getTechBase() == Part.T_CLAN); if (target.getValue() == TargetRoll.IMPOSSIBLE) { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='red'><b>Can't search for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + " because:</b></font> " + target.getDesc()); } return false; } if(Compute.d6(2) < target.getValue()) { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='red'><b>No contacts available for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + "</b></font>"); } return false; } else { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='green'>Possible contact for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + "</font>"); } return true; } }</code><technical_language>This is checked in goShoppingByPlanet(ShoppingList), is place this method is called. A null person is current path</technical_language>

Target:
public boolean findContactForAcquisition(IAcquisitionWork acquisition, Person person, PlanetarySystem system) { DateTime currentDate = Utilities.getDateTimeDay(getCalendar()); TargetRoll target = getTargetForAcquisition(acquisition, person, false); target = system.getPrimaryPlanet().getAcquisitionMods(target, getDate(), getCampaignOptions(), getFaction(), acquisition.getTechBase() == Part.T_CLAN); if (target.getValue() == TargetRoll.IMPOSSIBLE) { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='red'><b>Can't search for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + " because:</b></font> " + target.getDesc()); } return false; } if(Compute.d6(2) < target.getValue()) { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='red'><b>No contacts available for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + "</b></font>"); } return false; } else { if(getCampaignOptions().usePlanetAcquisitionVerboseReporting()) { addReport("<font color='green'>Possible contact for " + acquisition.getAcquisitionName() + " on " + system.getPrintableName(currentDate) + "</font>"); } return true; } }
Source:
<code>public NamespaceExtractionCacheManager(final Lifecycle lifecycle, final ServiceEmitter serviceEmitter) { this.scheduledExecutorService = MoreExecutors.listeningDecorator( Executors.newScheduledThreadPool( 1, new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat("NamespaceExtractionCacheManager-%d") .setPriority(Thread.MIN_PRIORITY) .build() ) ); ExecutorServices.manageLifecycle(lifecycle, scheduledExecutorService); scheduledExecutorService.scheduleAtFixedRate( new Runnable() { @Override public void run() { try { <START> monitor(serviceEmitter); <END> } catch (Exception e) { log.error(e, "Error emitting namespace stats"); if (Thread.currentThread().isInterrupted()) { throw Throwables.propagate(e); } } } }, 1, 10, TimeUnit.MINUTES ); }</code><technical_language>This a Monitor</technical_language>

Target:
public NamespaceExtractionCacheManager(final Lifecycle lifecycle, final ServiceEmitter serviceEmitter) { this.scheduledExecutorService = new ScheduledThreadPoolExecutor( 1, new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat("NamespaceExtractionCacheManager-%d") .setPriority(Thread.MIN_PRIORITY) .build() ); ExecutorServices.manageLifecycle(lifecycle, scheduledExecutorService); scheduledExecutorService.scheduleAtFixedRate( new Runnable() { @Override public void run() { try { monitor(serviceEmitter); } catch (Exception e) { log.error(e, "Error emitting namespace stats"); if (Thread.currentThread().isInterrupted()) { throw Throwables.propagate(e); } } } }, 1, 10, TimeUnit.MINUTES ); }
Source:
<code>public void writeUrls(URI baseUri) { super.writeUrls(baseUri); <START> setUrl(UriComponentsBuilder.fromUri(baseUri).path("/rest/sample/tissueprocessing/{id}").buildAndExpand(getId()).toUriString()); <END> }</code><technical_language>url point regular detailed sample url (/rest/tree/sample/{id})</technical_language>

Target:
public void writeUrls(URI baseUri) { super.writeUrls(baseUri); setUrl(UriComponentsBuilder.fromUri(baseUri).path("/rest/tree/sample/{id}").buildAndExpand(getId()).toUriString()); }
Source:
<code>public boolean isComplete() { <START> return length() == Constants.OBJECT_ID_LENGTH * 2; <END> }</code><technical_language>OBJECT_ID_STRING_LENGTH</technical_language>

Target:
public boolean isComplete() { return length() == Constants.OBJECT_ID_STRING_LENGTH; }
Source:
<code>public static void parseTimePeriod(Map<Integer, Set<Integer>> geoAreaCodesForYears, JSONObject response) { try { JSONArray data = response.getJSONArray(DATA_KEY); for (int i = 0; i < data.length(); i++) { JSONObject o = (JSONObject) data.get(i); Integer year = o.getInt(TIME_PERIOD_START_KEY); Integer geoAreaCode = o.getInt(GEO_AREA_CODE_KEY); if(dataObjectValueTypeIsSupported(o)) { <START> geoAreaCodesForYears.merge(year, new HashSet<Integer>(Arrays.asList(geoAreaCode)), (oldSet,newSet) -> { <END> return Stream.of(oldSet,newSet).flatMap(x -> x.stream()).collect(Collectors.toSet()); }); } } } catch (JSONException e) { LOG.error("Error parsing time period selectors for indicator: " + e.getMessage(), e); } }</code><technical_language>merge complicated. More readable solution be: map.computeIfAbsent(year, -> new HashSet<>()).add(geoAreaCode);</technical_language>

Target:
public static void parseTimePeriod(Map<Integer, Set<Integer>> geoAreaCodesForYears, JSONObject response) { try { JSONArray data = response.getJSONArray(DATA_KEY); for (int i = 0; i < data.length(); i++) { JSONObject o = (JSONObject) data.get(i); String valueType = o.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)) { Integer year = o.getInt(TIME_PERIOD_START_KEY); Integer geoAreaCode = o.getInt(GEO_AREA_CODE_KEY); geoAreaCodesForYears.computeIfAbsent(year, k -> new HashSet<>()).add(geoAreaCode); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } } catch (JSONException e) { LOG.error("Error parsing time period selectors for indicator: " + e.getMessage(), e); } }
Source:
<code>private static Symbol isPlusAssignment(ExpressionStatementTree update) { if (update.expression().is(Kind.PLUS_ASSIGNMENT)) { AssignmentExpressionTree assignment = (AssignmentExpressionTree) update.expression(); ExpressionTree lhs = assignment.variable(); ExpressionTree rhs = assignment.expression(); <START> IdentifierTree identifier = (IdentifierTree) lhs; <END> if (isOne(rhs)) { return identifier.symbol(); } } return null; }</code><technical_language>This cast is safe, lhs MemberSelectExpressionTree field for (this.x = 0; this.x < 10; this.x += 1) { }</technical_language>

Target:
private static Symbol isPlusAssignment(ExpressionStatementTree update) { if (update.expression().is(Kind.PLUS_ASSIGNMENT)) { AssignmentExpressionTree assignment = (AssignmentExpressionTree) update.expression(); ExpressionTree lhs = assignment.variable(); ExpressionTree rhs = assignment.expression(); if (lhs.is(Kind.IDENTIFIER)) { IdentifierTree identifier = (IdentifierTree) lhs; if (isOne(rhs)) { return identifier.symbol(); } } } return null; }
Source:
<code>public java.util.Map<K, Collection<V>> toJavaMap() { final java.util.Map<K, Collection<V>> javaMap = new java.util.HashMap<>(); for (Tuple2<K, V> t : this) { javaMap.computeIfAbsent(t._1, k -> { if(emptyContainer.get() instanceof Set) { return new java.util.HashSet<>(); } else if(emptyContainer.get() instanceof SortedSet) { return new java.util.TreeSet<>(); } else { return new java.util.ArrayList<>(); } }).add(t._2); } <START> return javaMap; <END> }</code><technical_language>I move value-provider of loop. type check once. java final java.util.Map<K, Collection<V>> javaMap = new java.util.HashMap<>(); final Supplier<Collection<V>> javaContainerSupplier; if (containerType == SEQ) { javaContainerSupplier = java.util.ArrayList::new; } else if (containerType == SET) { javaContainerSupplier = java.util.HashSet::new; } else if (containerType == SORTED_SET) { javaContainerSupplier = java.util.TreeSet::new; } else { throw new IllegalStateException("Unknown ContainerType: " + containerType); } for (Tuple2<K, V> t : this) { javaMap.computeIfAbsent(t._1, -> javaContainerSupplier.get()).add(t._2); } return javaMap; if throw is if compiler complain javaContainerSupplier is uninitialized. If so, create a private method getJavaContainerSupplier()..</technical_language>

Target:
public java.util.Map<K, Collection<V>> toJavaMap() { final java.util.Map<K, Collection<V>> javaMap = new java.util.HashMap<>(); final Supplier<Collection<V>> javaContainerSupplier; if (containerType == ContainerType.SEQ) { javaContainerSupplier = java.util.ArrayList::new; } else if (containerType == ContainerType.SET) { javaContainerSupplier = java.util.HashSet::new; } else if (containerType == ContainerType.SORTED_SET) { javaContainerSupplier = java.util.TreeSet::new; } else { throw new IllegalStateException("Unknown ContainerType: " + containerType); } for (Tuple2<K, V> t : this) { javaMap.computeIfAbsent(t._1, k -> javaContainerSupplier.get()).add(t._2); } return javaMap; }
Source:
<code>private String getPatternSegmentName(ITmfEvent event) { StringBuilder name = new StringBuilder(PATTERN_SEGMENT_NAME_PREFIX); <START> ITmfXmlStateValue nameStateValue = null; <END> final @NonNull String segmentName = fTypeElement.getAttribute(TmfXmlStrings.SEGMENT_NAME); if (segmentName.isEmpty()) { Element elementSegmentNameStateValue = (Element) fTypeElement.getElementsByTagName(TmfXmlStrings.STATE_VALUE).item(0); if (elementSegmentNameStateValue == null) { throw new IllegalArgumentException("Failed to get the segment name. A state value is needed."); } nameStateValue = fModelFactory.createStateValue(elementSegmentNameStateValue, fContainer, new ArrayList<ITmfXmlStateAttribute>()); getSegmentNameValue(event, name, nameStateValue); } else { name.append(segmentName); } return name.toString(); }</code><technical_language>declare this in scope of if, is</technical_language>

Target:
private String getPatternSegmentName(ITmfEvent event) { return fSegmentType.getName(event); }
Source:
<code>public void setCurrentKey(K currentKey) throws Exception { if (currentKey != null && currentKey.equals(this.currentKey)) { return; } currentWatermark = Long.MAX_VALUE; InternalTimer<K, N> timer; <START> while ((timer = eventTimeTimersQueue.peek()) != null) { <END> eventTimeTimersQueue.poll(); triggerTarget.onEventTime(timer); } while ((timer = processingTimeTimersQueue.peek()) != null) { processingTimeTimersQueue.poll(); triggerTarget.onProcessingTime(timer); } currentWatermark = Long.MIN_VALUE; this.currentKey = currentKey; }</code><technical_language>I become: while ((timer = eventTimeTimersQueue.poll()) != null) { triggerTarget.onEventTime(timer); } for processing time</technical_language>

Target:
public void setCurrentKey(K currentKey) throws Exception { if (currentKey != null && currentKey.equals(this.currentKey)) { return; } currentWatermark = Long.MAX_VALUE; InternalTimer<K, N> timer; while ((timer = eventTimeTimersQueue.poll()) != null) { triggerTarget.onEventTime(timer); } while ((timer = processingTimeTimersQueue.poll()) != null) { triggerTarget.onProcessingTime(timer); } currentWatermark = Long.MIN_VALUE; this.currentKey = currentKey; }
Source:
<code>public void onStatusUpdate(ActiveMQStatus oldStatus, ActiveMQStatus newStatus) { if (oldStatus.equals(newStatus)) { return; } Reason reason; if (ActiveMQStatus.CONNECTED.equals(newStatus)) { reason = Reason.ACTIVEMQ_UP; } else if (ActiveMQStatus.DOWN.equals(newStatus)) { reason = Reason.ACTIVEMQ_DOWN; } else { <START> String msg = String.format("Could not transition candlpin mode: Unknown ActiveMQ status: %s", <END> newStatus); throw new IllegalArgumentException(msg); } transitionAppropriately(reason); }</code><technical_language>typo</technical_language>

Target:
public void onStatusUpdate(ActiveMQStatus oldStatus, ActiveMQStatus newStatus) { if (oldStatus.equals(newStatus)) { return; } Reason reason; if (ActiveMQStatus.CONNECTED.equals(newStatus)) { reason = Reason.ACTIVEMQ_UP; } else if (ActiveMQStatus.DOWN.equals(newStatus)) { reason = Reason.ACTIVEMQ_DOWN; } else { String msg = String.format("Could not transition candlepin mode: Unknown ActiveMQ status: %s", newStatus); throw new IllegalArgumentException(msg); } transitionAppropriately(reason); }
Source:
<code>public void stopRecording(Client c) { if (recordingStarted.compareAndSet(true, false)) { log.debug("##REC:: recording in room is stopping ::", roomId, recordingId); streamProcessor.getStreamsByRoom(this.getRoomId()).forEach( <START> stream -> stream.stopRecord() <END> ); Recording rec = streamProcessor.getRecordingDao().get(recordingId); rec.setRecordEnd(new Date()); rec = streamProcessor.getRecordingDao().update(rec); recordingUser = new JSONObject(); recordingId = null; streamProcessor.startConvertion(rec); User u; if (c == null) { u = new User(); } else { u = c.getUser(); Optional<StreamDesc> osd = c.getScreenStream(); if (osd.isPresent()) { osd.get().removeActivity(Activity.RECORD); streamProcessor.getClientManager().update(c); streamProcessor.getHandler().sendShareUpdated(osd.get()); } } WebSocketHelper.sendRoom(new RoomMessage(roomId, u, RoomMessage.Type.RECORDING_TOGGLED)); log.debug("##REC:: recording in room is stopped ::", roomId); } }</code><technical_language>this replaced KStream::stopRecord</technical_language>

Target:
public void stopRecording(Client c) { if (recordingStarted.compareAndSet(true, false)) { log.debug("##REC:: recording in room is stopping ::", roomId, recordingId); processor.getByRoom(this.getRoomId()).forEach(KStream::stopRecord); Recording rec = processor.getRecordingDao().get(recordingId); rec.setRecordEnd(new Date()); rec = processor.getRecordingDao().update(rec); recordingUser = new JSONObject(); recordingId = null; processor.startConvertion(rec); User u; if (c == null) { u = new User(); } else { u = c.getUser(); Optional<StreamDesc> osd = c.getScreenStream(); if (osd.isPresent()) { osd.get().removeActivity(Activity.RECORD); processor.getClientManager().update(c); processor.getHandler().sendShareUpdated(osd.get()); } } WebSocketHelper.sendRoom(new RoomMessage(roomId, u, RoomMessage.Type.RECORDING_TOGGLED)); log.debug("##REC:: recording in room is stopped ::", roomId); } }
Source:
<code>public void onTimer(String serverId, String volumeId, String snapshotNamePrefix, String description, boolean force) { final GlusterVolumeEntity volume = getGlusterVolumeDao().getById(new Guid(volumeId)); GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity(); <START> snapshot.setClusterId(volume.getClusterId()); <END> snapshot.setVolumeId(new Guid(volumeId)); DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); final String snapshotName = snapshotNamePrefix + "-snap-" + df.format(new Date()); snapshot.setSnapshotName(snapshotName); snapshot.setDescription(description); VdcReturnValueBase returnValue = getBackend().runInternalAction(VdcActionType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotParameters(snapshot, force)); if (!returnValue.getSucceeded()) { log.error("Error while creating snapshot for volume '{}': {}", volume.getName(), returnValue.getExecuteFailedMessages().toString()); log.debug(returnValue.getExecuteFailedMessages().toString()); logUtil.logAuditMessage(volume.getClusterId(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, new HashMap<String, String>() { { put(GlusterConstants.VOLUME_SNAPSHOT_NAME, snapshotName); put(GlusterConstants.VOLUME_NAME, volume.getName()); } }); } }</code><technical_language>check if volume is null log return</technical_language>

Target:
public void onTimer(String serverId, String volumeId, String snapshotNamePrefix, String description, boolean force) { final GlusterVolumeEntity volume = getGlusterVolumeDao().getById(new Guid(volumeId)); if (volume == null) { log.error("Error while creating volume snapshot. Volume is null."); return; } GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity(); snapshot.setClusterId(volume.getClusterId()); snapshot.setVolumeId(volume.getId()); DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); final String snapshotName = snapshotNamePrefix + "-snap-" + df.format(new Date()); snapshot.setSnapshotName(snapshotName); snapshot.setDescription(description); VdcReturnValueBase returnValue = getBackend().runInternalAction(VdcActionType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotParameters(snapshot, force)); if (!returnValue.getSucceeded()) { log.error("Error while creating snapshot for volume '{}': {}", volume.getName(), returnValue.getExecuteFailedMessages().toString()); logUtil.logAuditMessage(volume.getClusterId(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, new HashMap<String, String>() { { put(GlusterConstants.VOLUME_SNAPSHOT_NAME, snapshotName); put(GlusterConstants.VOLUME_NAME, volume.getName()); } }); } }
Source:
<code>public Observable<R> apply(T t) throws Exception { <START> return RxJavaPlugins.onAssembly(new SingleToObservable<R>(mapper.apply(t))); <END> }</code><technical_language>check mapper.apply(t) return null</technical_language>

Target:
public Observable<R> apply(T t) throws Exception { return RxJavaPlugins.onAssembly(new SingleToObservable<R>( ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null value"))); }
Source:
<code>public static CDOCheckout getCheckout(Object object) { <START> CDOCheckout checkout = null; <END> if (object instanceof CDOView) { CDOView view = (CDOView)object; if (!view.isClosed()) { checkout = (CDOCheckout)view.properties().get(CDOCheckoutImpl.CHECKOUT_KEY); } } if (object instanceof URI) { URI uri = (URI)object; checkout = CDOCheckoutViewProvider.getCheckout(uri); } else if (object instanceof String) { String id = (String)object; checkout = getCheckoutManager().getCheckout(id); } else { checkout = walkUp(object, null); } return checkout; }</code><technical_language>Please replace changes this: if (view.isClosed()) return null;</technical_language>

Target:
public static CDOCheckout getCheckout(Object object) { if (object instanceof CDOView) { CDOView view = (CDOView)object; if (view.isClosed()) { return null; } return (CDOCheckout)view.properties().get(CDOCheckoutImpl.CHECKOUT_KEY); } if (object instanceof URI) { URI uri = (URI)object; return CDOCheckoutViewProvider.getCheckout(uri); } if (object instanceof String) { String id = (String)object; return getCheckoutManager().getCheckout(id); } return walkUp(object, null); }