auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>void escapeMinimal() { String escapedText = XMLUtils.minimalEscape("a < a' && a' < a\" => a < a\""); assertFalse(escapedText.contains("<"), "Failed to escape <"); assertFalse(escapedText.contains("&&"), "Failed to escape &"); assertTrue(escapedText.contains(">"), "Failed to keep >"); assertTrue(escapedText.contains("'"), "Failed to keep '"); <START> assertTrue(escapedText.contains("\""), "Failed to keep \""); <END> }</code><technical_language>I find safer assert exact output output contains some strings. input string is long. easier difference expected actual test fails</technical_language>

Target:
void escapeMinimal() { String actual = XMLUtils.minimalEscape("a < a' && a' < a\" => a < a\""); assertEquals("a &#60; a' &#38;&#38; a' &#60; a\" => a &#60; a\"", actual); }
Source:
<code>public void createPartControl(final Composite parent) { fParentComposite = parent; IMenuManager menuManager = getViewSite().getActionBars() .getMenuManager(); <START> contributeNewActionToMenu(menuManager); <END> menuManager.add(new Separator()); if (this instanceof ITmfTimeAligned) { contributeAlignViewsActionToToolbar(); fControlListener = new ControlAdapter() { @Override public void controlResized(ControlEvent e) { TIME_ALIGNMENT_SYNCHRONIZER.handleViewResized(TmfView.this); } }; parent.addControlListener(fControlListener); getSite().getPage().addPartListener(new IPartListener() { @Override public void partOpened(IWorkbenchPart part) { } @Override public void partDeactivated(IWorkbenchPart part) { } @Override public void partClosed(IWorkbenchPart part) { if (part == TmfView.this && fControlListener != null && !fParentComposite.isDisposed()) { fParentComposite.removeControlListener(fControlListener); fControlListener = null; getSite().getPage().removePartListener(this); TIME_ALIGNMENT_SYNCHRONIZER.handleViewClosed(TmfView.this); } } @Override public void partBroughtToTop(IWorkbenchPart part) { } @Override public void partActivated(IWorkbenchPart part) { } }); } }</code><technical_language>Colors view, Filters view, LAMI Report view? distinct concepts for views send/receive TMF signals, views show trace data</technical_language>

Target:
public void createPartControl(final Composite parent) { fParentComposite = parent; if (this instanceof ITmfAllowMultiple) { contributeNewViewActionToMenu(); } if (this instanceof ITmfTimeAligned) { contributeAlignViewsActionToToolbar(); fControlListener = new ControlAdapter() { @Override public void controlResized(ControlEvent e) { e.display.asyncExec(() -> { TIME_ALIGNMENT_SYNCHRONIZER.handleViewResized(TmfView.this); }); } }; parent.addControlListener(fControlListener); getSite().getPage().addPartListener(new IPartListener() { @Override public void partOpened(IWorkbenchPart part) { } @Override public void partDeactivated(IWorkbenchPart part) { } @Override public void partClosed(IWorkbenchPart part) { if (part == TmfView.this && fControlListener != null && !fParentComposite.isDisposed()) { fParentComposite.removeControlListener(fControlListener); fControlListener = null; getSite().getPage().removePartListener(this); TIME_ALIGNMENT_SYNCHRONIZER.handleViewClosed(TmfView.this); } } @Override public void partBroughtToTop(IWorkbenchPart part) { } @Override public void partActivated(IWorkbenchPart part) { } }); } }
Source:
<code><START> protected void <END> logException(RuntimeException ex) { if (ex.getMessage() == null || !ex.getMessage().contains("Policy reset")) { log.error("Command '{}' execution failed: {}", this, ex.getMessage()); log.debug("Exception", ex); } }</code><technical_language>appears this change reverted</technical_language>

Target:
private void logException(RuntimeException ex) { if (ex.getMessage() == null || !ex.getMessage().contains("Policy reset")) { log.error("Command '{}' execution failed: {}", this, ex.getMessage()); log.debug("Exception", ex); } }
Source:
<code>protected boolean isURL() { final boolean debug = false; char nc = peek(1); switch (nc) { case ' ': case '\t': case '\r': case '\n': case '"': case '\'': return false; } State cs = this.getCurrent(); UrlValidation syntaxvalid = new UrlValidation(); int where; if ((where = syntaxvalid.isValid(text, cs.start)) != -1) { String ss = new String(text, cs.start, where - cs.start); try { if (new URI(ss) != null) { this.current = cs.start + (ss.length() - 1); this.pop(this.current + 1); if (debug) logger.info("Good : " + ss); return true; } } catch (URISyntaxException e) { if (debug) logger.info("Invalid : " + ss); return false; } } else { if (debug) { int len = Math.min(100, text.length - cs.start); String ss = new String(text, cs.start, len); <START> logger.info("Not even close : " + ss); <END> } } return false; }</code><technical_language>this is in a conditional block a flag named 'debug', I assume intent is display output immediately -- STDERR</technical_language>

Target:
protected boolean isURL() { final boolean debug = false; char nc = peek(1); switch (nc) { case ' ': case '\t': case '\r': case '\n': case '"': case '\'': return false; } State cs = this.getCurrent(); UrlValidation syntaxvalid = new UrlValidation(); int where; if ((where = syntaxvalid.isValid(text, cs.start)) != -1) { String ss = new String(text, cs.start, where - cs.start); try { if (new URI(ss) != null) { this.current = cs.start + (ss.length() - 1); this.pop(this.current + 1); if (debug) System.err.println("Good : " + ss); return true; } } catch (URISyntaxException e) { if (debug) System.err.println("Invalid : " + ss); return false; } } else { if (debug) { int len = Math.min(100, text.length - cs.start); String ss = new String(text, cs.start, len); System.err.println("Not even close : " + ss); } } return false; }
Source:
<code>public void setUserPages(UserPages userPages) { this.userPages = userPages; <START> userPagesNull = false; <END> }</code><technical_language>Good call. Whoops. Although, want check if new userPages object is null, possibly set true, in case is null out. :)</technical_language>

Target:
public void setUserPages(UserPages userPages) { this.userPages = userPages; if (userPages == null) { userPagesNull = true; } else { userPagesNull = false; } }
Source:
<code>public static Object[][] parameters() { return new Object[][]{ new Object[]{false, true, Arrays.asList(cancel(20), checkpoint(10))}, new Object[]{false, true, Arrays.asList(cancel(10), checkpoint(10))}, new Object[]{true, true, Arrays.asList(cancel(10), checkpoint(20))}, new Object[]{true, true, Arrays.asList(checkpoint(10), cancel(10))}, <START> new Object[]{true, true, Arrays.asList(checkpoint(10), cancel(20))}, <END> }; }</code><technical_language>I guess easily add some more cases, checkpoint(20), cancel(10) cancel(10), cancel(20) cancel(20), cancel(10) some carefully chosen combination of 3 events</technical_language>

Target:
public static Object[][] parameters() { return new Object[][]{ new Object[]{false, true, Arrays.asList(cancel(10), cancel(20)), 1, 0}, new Object[]{false, true, Arrays.asList(cancel(20), cancel(10)), 1, 0}, new Object[]{false, true, Arrays.asList(cancel(10), checkpoint(10)), 1, 0}, new Object[]{true, true, Arrays.asList(cancel(10), checkpoint(20)), 1, 0}, new Object[]{false, true, Arrays.asList(cancel(20), checkpoint(10)), 1, 0}, new Object[]{true, false, Arrays.asList(checkpoint(10), checkpoint(10)), 1, 0}, new Object[]{true, false, Arrays.asList(checkpoint(10), checkpoint(20)), 1, 0}, new Object[]{true, true, Arrays.asList(checkpoint(10), checkpoint(20)), 2, 0}, new Object[]{true, false, Arrays.asList(checkpoint(20), checkpoint(10)), 1, 0}, new Object[]{true, true, Arrays.asList(checkpoint(10), cancel(10)), 1, 0}, new Object[]{true, true, Arrays.asList(checkpoint(10), cancel(20)), 1, 0}, new Object[]{true, true, Arrays.asList(checkpoint(20), cancel(10)), 1, 0}, }; }
Source:
<code>public void handleRequests(Request request) throws InterruptedException { try { DataInputStream stream = new DataInputStream(request.getInputStream()); RequestResponseType type = RequestResponseType.values()[stream.readShort()]; switch (type) { case PutRequest: handlePutRequest(request); break; case GetRequest: handleGetRequest(request); break; case DeleteRequest: handleDeleteRequest(request); break; case TTLRequest: handleTTLRequest(request); break; <START> default: throw new UnsupportedOperationException("Request type not supported"); <END> } } catch (Exception e) { requestResponseChannel.closeConnection(request); } }</code><technical_language>this exception is caught immediately effectively swallowed. logger.error connection is closed rational for closeConnection call in logs</technical_language>

Target:
public void handleRequests(Request request) throws InterruptedException { try { DataInputStream stream = new DataInputStream(request.getInputStream()); RequestResponseType type = RequestResponseType.values()[stream.readShort()]; switch (type) { case PutRequest: handlePutRequest(request); break; case GetRequest: handleGetRequest(request); break; case DeleteRequest: handleDeleteRequest(request); break; case TTLRequest: handleTTLRequest(request); break; default: throw new UnsupportedOperationException("Request type not supported"); } } catch (Exception e) { logger.error("Error while handling request {}. Closing connection", e); requestResponseChannel.closeConnection(request); } }
Source:
<code><START> public String[] getMechanismNames(final Map<String, ?> props) { <END> return new String[] {SaslMechanismInformation.Names.OAUTHBEARER,}; }</code><technical_language>Assuming filtering properties apply</technical_language>

Target:
public String[] getMechanismNames(final Map<String, ?> props) { if ("true".equals(props.get(WildFlySasl.MECHANISM_QUERY_ALL))) { return new String[] {SaslMechanismInformation.Names.OAUTHBEARER}; } if ("true".equals(props.get(Sasl.POLICY_NOPLAINTEXT)) || "true".equals(props.get(Sasl.POLICY_NOACTIVE)) || "true".equals(props.get(Sasl.POLICY_NODICTIONARY))) { return new String[] {}; } return new String[] {SaslMechanismInformation.Names.OAUTHBEARER}; }
Source:
<code>public boolean shouldVendorBeSentToPaymentWorks(VendorDetail vendorDetail) { boolean sendToPaymentWorks = vendorDetail.isActiveIndicator() <START> && !(StringUtils.equals(vendorDetail.getVendorHeader().getVendorOwnershipCategoryCode(), "US") <END> || StringUtils.equals(vendorDetail.getVendorHeader().getVendorOwnershipCategoryCode(), "NU") || StringUtils.equals(vendorDetail.getVendorHeader().getVendorOwnershipCategoryCode(), "SE") || StringUtils.equals(vendorDetail.getVendorHeader().getVendorOwnershipCategoryCode(), "UE") || StringUtils.equals(vendorDetail.getVendorHeader().getVendorOwnershipCategoryCode(), "AE")); LOG.debug("shouldVendorBeSentToPaymentWorks1, sendToPaymentWorks: " + sendToPaymentWorks); return sendToPaymentWorks; }</code><technical_language>a system parameter a list of vendor ownership category codes supposed Payment Works? this code call a ParameterEvaluator check if vendor ownership category code is allowed</technical_language>

Target:
public boolean shouldVendorBeSentToPaymentWorks(VendorDetail vendorDetail) { boolean sendToPaymentWorks = vendorDetail.isActiveIndicator() && isVendorTypeSendableToPaymentWorks(vendorDetail.getVendorHeader().getVendorTypeCode()); LOG.debug("shouldVendorBeSentToPaymentWorks1, sendToPaymentWorks: " + sendToPaymentWorks); return sendToPaymentWorks; }
Source:
<code>public void initialize(URL location, ResourceBundle resources) { treeViewWrapper = new TreeViewWrapper<>(astTreeView); astTreeView.setCellFactory(treeView -> new ASTTreeCell(parent)); languageVersionProperty().values() .filterMap(Objects::nonNull, LanguageVersion::getLanguage) .distinct() .subscribe(this::updateSyntaxHighlighter); EventStreams.valuesOf(astTreeView.getSelectionModel().selectedItemProperty()) .filterMap(Objects::nonNull, TreeItem::getValue) .subscribe(parent::onNodeItemSelected); codeEditorArea.richChanges() .filter(t -> !t.getInserted().equals(t.getRemoved())) <START> .successionEnds(Duration.ofMillis(100)) <END> .subscribe(richChange -> parent.onRefreshASTClicked()); codeEditorArea.setParagraphGraphicFactory(LineNumberFactory.get(codeEditorArea)); }</code><technical_language>abstract duration a named constant</technical_language>

Target:
public void initialize(URL location, ResourceBundle resources) { treeViewWrapper = new TreeViewWrapper<>(astTreeView); astTreeView.setCellFactory(treeView -> new ASTTreeCell(parent)); languageVersionProperty().values() .filterMap(Objects::nonNull, LanguageVersion::getLanguage) .distinct() .subscribe(this::updateSyntaxHighlighter); EventStreams.valuesOf(astTreeView.getSelectionModel().selectedItemProperty()) .filterMap(Objects::nonNull, TreeItem::getValue) .subscribe(parent::onNodeItemSelected); codeEditorArea.richChanges() .filter(t -> !t.getInserted().equals(t.getRemoved())) .successionEnds(CODE_EDITOR_REFRESH) .subscribe(richChange -> parent.refreshAST()); codeEditorArea.setParagraphGraphicFactory(LineNumberFactory.get(codeEditorArea)); }
Source:
<code><START> public ViewerActionContext<? <END> extends Viewer> getActionContext() { return actionContext; }</code><technical_language>this protected well</technical_language>

Target:
protected ViewerActionContext<? extends Viewer> getActionContext() { return actionContext; }
Source:
<code>public void addIndexerToCorfuTableStream(String streamName, IndexRegistry indexRegistry) { UUID streamId = CorfuRuntime.getStreamID(streamName); SMRObject.Builder ob = SMRObject.builder() .runtime(runtime) .setType(CorfuTable.class) <START> .setArguments(indexRegistry) <END> .setStreamID(streamId); addCustomTypeStream(streamId, ob); }</code><technical_language>type(CorfuTable) instead of setType</technical_language>

Target:
public void addIndexerToCorfuTableStream(String streamName, IndexRegistry indexRegistry) { UUID streamId = CorfuRuntime.getStreamID(streamName); Builder ob = SMRObject.builder() .runtime(runtime) .setType(CorfuTable.class) .setArguments(indexRegistry) .setStreamID(streamId); addCustomTypeStream(streamId, ob); }
Source:
<code>private void init() { <START> fields = new ArrayList<Field>(); <END> List<String> headers = new ArrayList<String>(); List<Integer> fieldWidth = new ArrayList<Integer>(); for (String tmp : fieldDescription.split(",")) { String[] fieldTuple = tmp.split(":(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); Field field = new Field(); field.setName(fieldTuple[0]); field.setType(fieldTuple[1]); headers.add(fieldTuple[0]); fieldWidth.add(Integer.parseInt(fieldTuple[2])); if (field.getType() == FIELD_TYPE.DATE) { if (fieldTuple.length > 3) { fieldDateFormat.put(field.getName(), fieldTuple[3].replace("\"", "")); } else { logger.error("Date format is missing for the field {}", field.getName()); throw new RuntimeException("Missing date format"); } } fields.add(field); } header = headers.toArray(new String[headers.size()]); width = Ints.toArray(fieldWidth); FixedWidthFieldLengths lengths = new FixedWidthFieldLengths(header, width); FixedWidthParserSettings settings = new FixedWidthParserSettings(lengths); settings.getFormat().setPadding(this.padding); fixedWidthParser = new FixedWidthParser(settings); }</code><technical_language>new ArrayList<>();</technical_language>

Target:
private void init() { fields = new ArrayList<FixedWidthField>(); List<String> headers = new ArrayList<String>(); List<Integer> fieldWidth = new ArrayList<Integer>(); for (String tmp : fieldDescription.split(",")) { String[] fieldTuple = tmp.split(":(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); FixedWidthField field = new FixedWidthField(); field.setName(fieldTuple[0]); field.setType(fieldTuple[1]); field.setWidth(Integer.parseInt(fieldTuple[2])); headers.add(fieldTuple[0]); fieldWidth.add(Integer.parseInt(fieldTuple[2])); if (field.getType() == FIELD_TYPE.DATE) { if (fieldTuple.length > 3) { field.setDateFormat(fieldTuple[3].replace("\"", "")); } else { logger.error("Date format is missing for the field {}", field.getName()); throw new RuntimeException("Missing date format"); } } fields.add(field); } header = headers.toArray(new String[headers.size()]); int[] width = Ints.toArray(fieldWidth); FixedWidthFields lengths = new FixedWidthFields(header, width); FixedWidthParserSettings settings = new FixedWidthParserSettings(lengths); settings.getFormat().setPadding(this.padding); fixedWidthParser = new FixedWidthParser(settings); }
Source:
<code>public static Predicate<Object> isStringStartingWith(final String prefix) { return Predicates.<Object>and(Predicates.instanceOf(CharSequence.class), <START> Predicates.compose(new StartsWith<String>(prefix), StringFunctions.toStringFunction())); <END> }</code><technical_language>startsWith(prefix), calling this constructor directly</technical_language>

Target:
public static Predicate<Object> isStringStartingWith(final String prefix) { return Predicates.<Object>and(Predicates.instanceOf(CharSequence.class), Predicates.compose(startsWith(prefix), StringFunctions.toStringFunction())); }
Source:
<code>public Response processStats(BatchedOperatorStats stats) { Response response = new Response(); response.repartitionRequired = false; if (!partitionedInstanceStatus.containsKey(stats.getOperatorId())) { return response; } partitionedInstanceStatus.put(stats.getOperatorId(), stats); if (getLoad(stats) != 0) { logger.debug("repartition{}, currentTimeMillis {}, nextMillis {}, diff{}", repartition, System.currentTimeMillis(), nextMillis, nextMillis - System.currentTimeMillis()); if (repartition && System.currentTimeMillis() > nextMillis) { repartition = false; <START> logger.debug("AAAAAAAAAAAAA"); <END> response.repartitionRequired = true; logger.debug("setting repartition to true"); } else if (!repartition) { repartition = true; logger.debug("BBBBBBBBBB"); nextMillis = System.currentTimeMillis() + cooldownMillis; } } else { repartition = false; } return response; }</code><technical_language>Please add proper debug message delete if necessary</technical_language>

Target:
public Response processStats(BatchedOperatorStats stats) { Response response = new Response(); response.repartitionRequired = false; if (!partitionedInstanceStatus.containsKey(stats.getOperatorId())) { return response; } partitionedInstanceStatus.put(stats.getOperatorId(), stats); if (getLoad(stats) != 0) { if (repartition && System.currentTimeMillis() > nextMillis) { repartition = false; response.repartitionRequired = true; logger.debug("setting repartition to true"); } else if (!repartition) { repartition = true; nextMillis = System.currentTimeMillis() + cooldownMillis; } } else { repartition = false; } return response; }
Source:
<code>public void testEnableTetheringPermission() throws Exception { if (!mTM.isTetheringSupported()) return; final TestTetheringEventCallback tetherEventCallback = new TestTetheringEventCallback(); mTM.registerTetheringEventCallback(c -> <START> c.run(), tetherEventCallback); <END> tetherEventCallback.expectCallbackStarted(); final TestSoftApCallback softApCallback = new TestSoftApCallback(); mWm.registerSoftApCallback(c -> c.run(), softApCallback); final StartTetheringCallback wifiCallback = new StartTetheringCallback(); mTM.startTethering(new TetheringRequest.Builder(TETHERING_WIFI).build(), c -> c.run(), wifiCallback); wifiCallback.verifyTetheringStarted(); PollingCheck.check( "No WIFI_AP_STATE_ENABLED state change", 5_000, () -> { return softApCallback.expectSoftApState(WifiManager.WIFI_AP_STATE_ENABLED); }); mTM.stopAllTethering(); PollingCheck.check( "No WIFI_AP_STATE_DISABLED state change", 5_000, () -> { return softApCallback.expectSoftApState(WifiManager.WIFI_AP_STATE_DISABLED); }); mTM.unregisterTetheringEventCallback(tetherEventCallback); mUiAutomation.dropShellPermissionIdentity(); mTM.startTethering(new TetheringRequest.Builder(TETHERING_WIFI).build(), c -> c.run(), wifiCallback); wifiCallback.expectTetheringFailed(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION); }</code><technical_language>Nit: add /* executor */ (also below)</technical_language>

Target:
public void testEnableTetheringPermission() throws Exception { if (!mTM.isTetheringSupported()) return; final TestTetheringEventCallback tetherEventCallback = new TestTetheringEventCallback(); mTM.registerTetheringEventCallback(c -> c.run(), tetherEventCallback); tetherEventCallback.expectCallbackStarted(); final TestSoftApCallback softApCallback = new TestSoftApCallback(); mWm.registerSoftApCallback(c -> c.run(), softApCallback); final StartTetheringCallback wifiCallback = new StartTetheringCallback(); mTM.startTethering(new TetheringRequest.Builder(TETHERING_WIFI).build(), c -> c.run(), wifiCallback); wifiCallback.verifyTetheringStarted(); softApCallback.expectSoftApState(WifiManager.WIFI_AP_STATE_ENABLED, DEFAULT_TIMEOUT_MS); mTM.stopAllTethering(); softApCallback.expectSoftApState(WifiManager.WIFI_AP_STATE_DISABLED, DEFAULT_TIMEOUT_MS); mTM.unregisterTetheringEventCallback(tetherEventCallback); mUiAutomation.dropShellPermissionIdentity(); mTM.startTethering(new TetheringRequest.Builder(TETHERING_WIFI).build(), c -> c.run(), wifiCallback); wifiCallback.expectTetheringFailed(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION); }
Source:
<code>private void merge(Map<String, StageState> files, boolean showPrompt, String toolNamePrompt) throws Exception { List<String> fileNames = new ArrayList<>(files.keySet()); Collections.sort(fileNames); outw.println("Merging:"); for (String fileName : fileNames) { outw.println(fileName); <START> } <END> for (String fileName : fileNames) { StageState fileState = files.get(fileName); if (fileState == StageState.BOTH_MODIFIED) { outw.println("\nNormal merge conflict for '" + fileName + "':"); outw.println(" {local}: modified file"); outw.println(" {remote}: modified file"); boolean launch = true; if (showPrompt) { launch = isLaunch(toolNamePrompt); } if (launch) { outw.println("TODO: Launch mergetool '" + toolNamePrompt + "' for path '" + fileName + "'..."); } else { break; } } else if ((fileState == StageState.DELETED_BY_US) || (fileState == StageState.DELETED_BY_THEM)) { outw.println("\nDeleted merge conflict for '" + fileName + "':"); } else { outw.println( "\nUnknown merge conflict for '" + fileName + "':"); break; } } }</code><technical_language>in case of prompt output is printed console start of tool, I suggest adding a outw.flush() right here</technical_language>

Target:
private void merge(Map<String, StageState> files, boolean showPrompt, String toolNamePrompt) throws Exception { List<String> fileNames = new ArrayList<>(files.keySet()); Collections.sort(fileNames); outw.println("Merging:"); for (String fileName : fileNames) { outw.println(fileName); } outw.flush(); for (String fileName : fileNames) { StageState fileState = files.get(fileName); if (fileState == StageState.BOTH_MODIFIED) { outw.println("\nNormal merge conflict for '" + fileName + "':"); outw.println(" {local}: modified file"); outw.println(" {remote}: modified file"); boolean launch = true; if (showPrompt) { launch = isLaunch(toolNamePrompt); } if (launch) { outw.println("TODO: Launch mergetool '" + toolNamePrompt + "' for path '" + fileName + "'..."); } else { break; } } else if ((fileState == StageState.DELETED_BY_US) || (fileState == StageState.DELETED_BY_THEM)) { outw.println("\nDeleted merge conflict for '" + fileName + "':"); } else { outw.println( "\nUnknown merge conflict for '" + fileName + "':"); break; } } }
Source:
<code>protected String appendHash(String name, String toBeHashed) { <START> return Joiner.on("").join(name, DELIMITER, DigestUtils.md5DigestAsHex(toBeHashed.getBytes()).substring(0, DATE_FORMAT.length())); <END> }</code><technical_language>I pass cut length param instead of DATE_FORMAT.length</technical_language>

Target:
protected String appendHash(String name, String toBeHashed) { return appendHash(name, toBeHashed, getDefaultHashLength()); }
Source:
<code>public void revertFile() throws IOException { <START> OutputStream fileOutputStream = Files.newOutputStream(Paths.get(pathOfOldMetaFormat)); <END> fileOutputStream.write(testMetaOldFormat); fileOutputStream.close(); fileOutputStream = Files.newOutputStream( Paths.get("src/test/resources/testmetaUnsupportedFormat.xml")); fileOutputStream.write(testmetaUnsupportedFormat); fileOutputStream.close(); }</code><technical_language>do this IOUtils.write(), too</technical_language>

Target:
public void revertFile() throws IOException { IOUtils.write( testMetaOldFormat, Files.newOutputStream(Paths.get(pathOfOldMetaFormat))); IOUtils.write( testmetaUnsupportedFormat, Files.newOutputStream(Paths.get("src/test/resources/testmetaUnsupportedFormat.xml"))); }
Source:
<code>public IterableStream<byte[]> getData() { if (bodyType != AmqpMessageBodyType.DATA) { throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format("Can not return data for a " + "message which is of type %s.", getBodyType().toString()))); } <START> return new IterableStream<>(Collections.singletonList(data)); <END> }</code><technical_language>do create a new singletonList time getData() is called? create singletonList fromData() is called</technical_language>

Target:
public IterableStream<byte[]> getData() { if (bodyType != AmqpMessageBodyType.DATA) { throw logger.logExceptionAsError(new IllegalArgumentException( "This method can only be called for AMQP Data body type at present. Track this issue, " + "<LINK_0> for other body type support in " + "future.")); } if (dataList == null) { dataList = Collections.singletonList(data); } return new IterableStream<>(dataList); }
Source:
<code>public SecureBoot(SystemService systemService) { this.systemService = systemService; try { ddfHome = getDdfHome(); userHome = getUserHome(); } catch (IOException e) { String message = "Unable to determine if your installation [" + ddfHome + "] is located in an insecure directory. See log for details. Shutting down..."; System.err.println("\n" + message + "\n"); <START> LOGGER.error(message, e); <END> shutdown(); } }</code><technical_language>Do want log exceptions stack trace ERROR level? stack trace done DEBUG instead</technical_language>

Target:
public SecureBoot(SystemService systemService) { this.systemService = systemService; ddfHome = getDdfHome(); userHome = getUserHome(); }
Source:
<code>public Page<TaskInfo> getTasks(final long from, final long to, final String tag, final int offset, final int limit, final String user, final boolean pending, final boolean running, final boolean finished) { DBTaskDataParameters parameters = new DBTaskDataParameters(tag, from, to, offset, limit, user, <START> pending, running, finished, new SortSpecifierContainer()); <END> int totalNbTasks = getTotalNumberOfTasks(parameters); List<TaskInfo> lTaskInfo = runWithoutTransaction(TaskDBUtils.taskInfoSessionWork(parameters)); return new Page<TaskInfo>(lTaskInfo, totalNbTasks); }</code><technical_language>empty container places sense create store a class instance</technical_language>

Target:
public Page<TaskInfo> getTasks(final long from, final long to, final String tag, final int offset, final int limit, final String user, final boolean pending, final boolean running, final boolean finished) { DBTaskDataParameters parameters = new DBTaskDataParameters(tag, from, to, offset, limit, user, pending, running, finished, SortSpecifierContainer.EMPTY_CONTAINER); int totalNbTasks = getTotalNumberOfTasks(parameters); List<TaskInfo> lTaskInfo = runWithoutTransaction(TaskDBUtils.taskInfoSessionWork(parameters)); return new Page<TaskInfo>(lTaskInfo, totalNbTasks); }
Source:
<code>public void init(TransactionManager transactionManager) { successfullyInvoked = transactionManager.getKeyValueServiceStatus() == KeyValueServiceStatus.HEALTHY_ALL_OPERATIONS; while (block) { try { Thread.sleep(50); } catch (InterruptedException e) { <START> throw new RuntimeException(e); <END> } } }</code><technical_language>This is a test issue, please re-interrupt (Thread.currentThread().interrupt()) Awaitility if available</technical_language>

Target:
public void init(TransactionManager transactionManager) { successfullyInvoked = transactionManager.getKeyValueServiceStatus() == KeyValueServiceStatus.HEALTHY_ALL_OPERATIONS; while (block) { try { Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } }
Source:
<code>public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case Constants.ACTIVITY_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION: if (PermissionUtil.isPermitted(grantResults)) { <START> WikipediaApp.getInstance().getBus().post(new GrantStoragePermissionEvent()); <END> searchOfflineCompilations(true); } else { L.i("Write permission was denied by user"); onOfflineCompilationsError(new RuntimeException(getString(R.string.offline_read_permission_error))); if (PermissionUtil.shouldShowWritePermissionRationale(this)) { showStoragePermissionSnackbar(); } else { showAppSettingSnackbar(); } } break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); } }</code><technical_language>Instead of a Bus event, SettingsActivity override onOfflineCompilationsFound() method, update preference true if method is called. (we're onOfflineCompilationsError() for a similar purpose.)</technical_language>

Target:
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case Constants.ACTIVITY_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION: if (PermissionUtil.isPermitted(grantResults)) { searchOfflineCompilations(true); } else { L.i("Write permission was denied by user"); onOfflineCompilationsError(new RuntimeException(getString(R.string.offline_read_permission_error))); if (PermissionUtil.shouldShowWritePermissionRationale(this)) { showStoragePermissionSnackbar(); } else { showAppSettingSnackbar(); } } break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); } }
Source:
<code>private Transaction registerTransaction(int txId, int status, String name, long logId, RollbackListener listener) { int transactionId; long sequenceNo; boolean success; do { VersionedBitSet original = openTransactions.get(); if (txId == 0) { transactionId = original.nextClearBit(1); } else { transactionId = txId; assert !original.get(transactionId); } if (transactionId > maxTransactionId) { throw DataUtils.newIllegalStateException( DataUtils.ERROR_TOO_MANY_OPEN_TRANSACTIONS, "There are {0} open transactions", transactionId - 1); } VersionedBitSet clone = original.cloneIt(); clone.set(transactionId); sequenceNo = clone.getVersion() + 1; clone.setVersion(sequenceNo); success = openTransactions.compareAndSet(original, clone); <START> } while(!success); <END> Transaction transaction = new Transaction(this, transactionId, sequenceNo, status, name, logId, listener); success = transactions.compareAndSet(transactionId, null, transaction); assert success; return transaction; }</code><technical_language>success variable improves readability. Loops controlled some flag more time understood this flag is assigned assignment is nearby. compareAndSet() moved while condition</technical_language>

Target:
private Transaction registerTransaction(int txId, int status, String name, long logId, RollbackListener listener) { int transactionId; long sequenceNo; boolean success; do { VersionedBitSet original = openTransactions.get(); if (txId == 0) { transactionId = original.nextClearBit(1); } else { transactionId = txId; assert !original.get(transactionId); } if (transactionId > maxTransactionId) { throw DataUtils.newIllegalStateException( DataUtils.ERROR_TOO_MANY_OPEN_TRANSACTIONS, "There are {0} open transactions", transactionId - 1); } VersionedBitSet clone = original.clone(); clone.set(transactionId); sequenceNo = clone.getVersion() + 1; clone.setVersion(sequenceNo); success = openTransactions.compareAndSet(original, clone); } while(!success); Transaction transaction = new Transaction(this, transactionId, sequenceNo, status, name, logId, listener); assert transactions.get(transactionId) == null; transactions.set(transactionId, transaction); return transaction; }
Source:
<code>public String xpath() { XStreamDOM child = node.children.get(pos - 1); int count =0; for (int i=0; i<pos-1; i++) if (node.children.get(i).tagName.equals(child.tagName)) count++; boolean more = false; for (int i=pos; !more && i<node.children.size(); i++) if (node.children.get(i).tagName.equals(child.tagName)) { more = true; <START> break; <END> } if (count==0 && !more) return child.tagName; return child.tagName+'['+count+']'; }</code><technical_language>more is in for loop condition, need scare static code analysis :wink:</technical_language>

Target:
public String xpath() { XStreamDOM child = node.children.get(pos - 1); int count =0; for (int i=0; i<pos-1; i++) if (node.children.get(i).tagName.equals(child.tagName)) count++; boolean more = false; for (int i=pos; !more && i<node.children.size(); i++) if (node.children.get(i).tagName.equals(child.tagName)) more = true; if (count==0 && !more) return child.tagName; return child.tagName+'['+count+']'; }
Source:
<code>public OAuth20Profile extractUserProfile(final String body) { final OAuth20Profile profile = new OAuth20Profile(); final JsonNode json = JsonHelper.getFirstNode(body, getFirstNodePath()); if (json != null) { if (profileId != null) <START> profile.setId(ProfileHelper.sanitizeIdentifier(profile, JsonHelper.getElement(json, profileId))); <END> for (final String attribute : getPrimaryAttributes()) { convertAndAdd(profile, attribute, JsonHelper.getElement(json, attribute)); } for (final String attribute : getSecondaryAttributes()) { convertAndAdd(profile, attribute, JsonHelper.getElement(json, attribute)); } for (final Map.Entry<String, String> entry : getProfileAttributes().entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); convertAndAdd(profile, key, JsonHelper.getElement(json, value)); } } return profile; }</code><technical_language>brackets if clause</technical_language>

Target:
public OAuth20Profile extractUserProfile(final String body) { final OAuth20Profile profile = new OAuth20Profile(); final JsonNode json = JsonHelper.getFirstNode(body, getFirstNodePath()); if (json != null) { if (profileId != null) { profile.setId(ProfileHelper.sanitizeIdentifier(profile, JsonHelper.getElement(json, profileId))); } for (final String attribute : getPrimaryAttributes()) { convertAndAdd(profile, attribute, JsonHelper.getElement(json, attribute)); } for (final String attribute : getSecondaryAttributes()) { convertAndAdd(profile, attribute, JsonHelper.getElement(json, attribute)); } for (final Map.Entry<String, String> entry : getProfileAttributes().entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); convertAndAdd(profile, key, JsonHelper.getElement(json, value)); } } return profile; }
Source:
<code>public void enableStats(boolean statsEnabled) { if (statsEnabled) { this.countsEnabled = true; } this.statsEnabled = statsEnabled; <START> if (this.channelMetrics != null) { <END> this.channelMetrics.setFullStatsEnabled(statsEnabled); } }</code><technical_language>Redundant null check</technical_language>

Target:
public void enableStats(boolean statsEnabled) { if (statsEnabled) { this.countsEnabled = true; } this.statsEnabled = statsEnabled; this.channelMetrics.setFullStatsEnabled(statsEnabled); }
Source:
<code>private void increaseWriteIndex() { <START> if (curWriteIndex == maxSlotNum - 1) { <END> final long startLoopAt = System.currentTimeMillis(); while ((nextReadIndex == -1 || nextReadIndex == 0) && !Thread.interrupted()) { if (System.currentTimeMillis() - startLoopAt > timeoutMs) { throw new RuntimeException(new TimeoutException()); } } curWriteIndex = 0; } else { final int nextWriteIndex = curWriteIndex + 1; final long startLoopAt = System.currentTimeMillis(); while ((nextWriteIndex == nextReadIndex) && !Thread.interrupted()) { if (System.currentTimeMillis() - startLoopAt > timeoutMs) { throw new RuntimeException(new TimeoutException()); } } curWriteIndex = nextWriteIndex; } }</code><technical_language>Suggested "numSlots"</technical_language>

Target:
private void increaseWriteIndex() { final long startAtNs = System.nanoTime(); final long queryTimeoutAtNs = getQueryTimeoutAtNs(startAtNs); final long spinTimeoutAtNs = startAtNs + SPIN_FOR_TIMEOUT_THRESHOLD_NS; long timeoutNs = queryTimeoutAtNs - startAtNs; long spinTimeoutNs = SPIN_FOR_TIMEOUT_THRESHOLD_NS; if (curWriteIndex == maxNumSlots - 1) { while ((nextReadIndex == -1 || nextReadIndex == 0) && !Thread.currentThread().isInterrupted()) { if (timeoutNs <= 0L) { throw new RuntimeException(new TimeoutException()); } if (spinTimeoutNs <= 0L) { Thread.yield(); } long now = System.nanoTime(); timeoutNs = queryTimeoutAtNs - now; spinTimeoutNs = spinTimeoutAtNs - now; } curWriteIndex = 0; } else { final int nextWriteIndex = curWriteIndex + 1; while ((nextWriteIndex == nextReadIndex) && !Thread.currentThread().isInterrupted()) { if (timeoutNs <= 0L) { throw new RuntimeException(new TimeoutException()); } if (spinTimeoutNs <= 0L) { Thread.yield(); } long now = System.nanoTime(); timeoutNs = queryTimeoutAtNs - now; spinTimeoutNs = spinTimeoutAtNs - now; } curWriteIndex = nextWriteIndex; } }
Source:
<code>public void setBossBar(ServerBossBar bossBar) { <START> this.shadow$bossInfo = (ServerBossInfo) bossBar; <END> }</code><technical_language>suggestion this.shadow$bossInfo = checkNotNull((ServerBossInfo) bossBar, "BossBar null"); need statically import Preconditions.checkNotNull</technical_language>

Target:
public void setBossBar(ServerBossBar bossBar) { checkNotNull(bossBar, "BossBar cannot be null."); this.bossInfo = (ServerBossInfo) bossBar; }
Source:
<code>public static String primitiveToString(Object x) throws IOException { if (x != null) { if (x instanceof String) return (String)x; else if (x instanceof Boolean) return String.valueOf(x); else if (x instanceof Integer) return String.valueOf(x); else if (x instanceof Long) return String.valueOf(x); else if (x instanceof Float) return String.valueOf(x); else if (x instanceof Byte) return Byte.toString((Byte)x); else if (x instanceof Short) return Short.toString((Short)x); else if (x instanceof Double) return String.valueOf(x); else if (x instanceof BigDecimal) return ((BigDecimal)x).toString(); else if (x instanceof byte[]) return new String((byte[])x, StandardCharsets.UTF_8); else if (x instanceof Time) return ((Time)x).toString(); else if (x instanceof java.sql.Date) return ((java.sql.Date)x).toString(); else if (x instanceof Timestamp) return ((Timestamp)x).toString(); else if (x instanceof InputStream) { ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; <START> while ((length = ((InputStream)x).read(buffer)) != -1) <END> { result.write(buffer, 0, length); } return result.toString("UTF-8"); } else return (String)x; } else return null; }</code><technical_language>read read 1024 bytes? call read reading 1024 bytes is more read</technical_language>

Target:
public static String primitiveToString(Object x) throws IOException { if (x != null) { if (x instanceof String) return (String)x; else if (x instanceof Boolean) return String.valueOf(x); else if (x instanceof Integer) return String.valueOf(x); else if (x instanceof Long) return String.valueOf(x); else if (x instanceof Float) return String.valueOf(x); else if (x instanceof Byte) return Byte.toString((Byte)x); else if (x instanceof Short) return Short.toString((Short)x); else if (x instanceof Double) return String.valueOf(x); else if (x instanceof BigDecimal) return ((BigDecimal)x).toString(); else if (x instanceof byte[]) return new String((byte[])x, StandardCharsets.UTF_8); else if (x instanceof Time) return ((Time)x).toString(); else if (x instanceof java.sql.Date) return ((java.sql.Date)x).toString(); else if (x instanceof Timestamp) return ((Timestamp)x).toString(); else if (x instanceof InputStream) { ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = ((InputStream)x).read(buffer)) != -1) { result.write(buffer, 0, length); if (length < buffer.length) break; } return result.toString("UTF-8"); } else return (String)x; } else return null; }
Source:
<code>private int getMaxQueryComplexity(JSONObject policyDefinition) { Object complexityObject = policyDefinition.get(APIConstants.QUERY_ANALYSIS_COMPLEXITY); boolean complexityCheckEnabled = Boolean.parseBoolean(((JSONObject) complexityObject).get("enabled").toString()); if (complexityCheckEnabled) { <START> Object maxQueryComplexity = ((JSONObject) complexityObject).get("max_query_complexity"); <END> if (maxQueryComplexity != null) { return ((Long) maxQueryComplexity).intValue(); } else { log.error("Maximum query complexity was not allocated"); return -1; } } else { return -1; } }</code><technical_language>please create constants for strings these</technical_language>

Target:
private int getMaxQueryComplexity(JSONObject policyDefinition) { Object complexityObject = policyDefinition.get(APIConstants.QUERY_ANALYSIS_COMPLEXITY); boolean complexityCheckEnabled = Boolean.parseBoolean(((JSONObject) complexityObject) .get(APIConstants.CHECK_ENABLED).toString()); if (complexityCheckEnabled) { Object maxQueryComplexity = ((JSONObject) complexityObject).get(APIConstants.MAXIMUM_QUERY_COMPLEXITY); if (maxQueryComplexity != null) { return ((Long) maxQueryComplexity).intValue(); } else { log.error("Maximum query complexity was not allocated"); return -1; } } else { return -1; } }
Source:
<code>public void test_DnDClassFromContainer2ContainerBlank5() throws Exception { test_DnDClassFromMC2ContainerBlank5(); try { openErrorLogViewByAPI(); SWTBot errorLogBot = bot.viewByTitle("Error Log").bot(); int rowCount = errorLogBot.tree().rowCount(); DndUtil util = new DndUtil(bot.getDisplay()); SWTBotGefEditPart p1Bot = editor.getEditPart(CONTAINER_TO_DRAG_P1).parent(); Point targetLocation = editor.getBounds(p1Bot).getLeft().getTranslated(-200, 0); final SWTBotTreeItem ecoreTreeItem = semanticResourceNode.expandNode(ROOTPACKAGE_NAME) .getNode(CONTAINER_TO_DRAG_P2); <START> System.out.println("Cas2 --> \"P2\" = " + ecoreTreeItem.getText()); <END> util.dragAndDrop(ecoreTreeItem, editor.getCanvas(), new org.eclipse.swt.graphics.Point(targetLocation.x, targetLocation.y)); bot.waitUntil(new DiagramWithChildrensCondition(editor, 2)); assertEquals("An error message was generated !", rowCount, errorLogBot.tree().rowCount()); SWTBotGefEditPart c1Bot = editor.getEditPart(CLASS_TO_DRAG_C1).parent(); Point c1Location = editor.getBounds(c1Bot).getLocation(); SWTBotGefEditPart targetSwtBotPart = editor.getEditPart(CONTAINER_TO_DRAG_P2, AbstractDiagramContainerEditPart.class); final IGraphicalEditPart targetPart = (IGraphicalEditPart) targetSwtBotPart.part(); Point targetCenter = targetPart.getFigure().getBounds().getCenter(); editor.drag(c1Location, targetCenter); assertEquals("An error message was generated !", rowCount, errorLogBot.tree().rowCount()); } finally { closeErrorLogView(); } }</code><technical_language>remove</technical_language>

Target:
public void test_DnDClassFromContainer2ContainerBlank5() throws Exception { test_DnDClassFromMC2ContainerBlank5(); try { openErrorLogViewByAPI(); SWTBot errorLogBot = bot.viewByTitle("Error Log").bot(); int rowCount = errorLogBot.tree().rowCount(); DndUtil util = new DndUtil(bot.getDisplay()); SWTBotGefEditPart p1Bot = editor.getEditPart(CONTAINER_TO_DRAG_P1).parent(); Point targetLocation = editor.getBounds(p1Bot).getLeft().getTranslated(-200, 0); final SWTBotTreeItem ecoreTreeItem = semanticResourceNode.expandNode(ROOTPACKAGE_NAME) .getNode(CONTAINER_TO_DRAG_P2); util.dragAndDrop(ecoreTreeItem, editor.getCanvas(), new org.eclipse.swt.graphics.Point(targetLocation.x, targetLocation.y)); bot.waitUntil(new DiagramWithChildrensCondition(editor, 2)); assertEquals("An error message was generated !", rowCount, errorLogBot.tree().rowCount()); SWTBotGefEditPart c1Bot = editor.getEditPart(CLASS_TO_DRAG_C1).parent(); Point c1Location = editor.getBounds(c1Bot).getLocation(); SWTBotGefEditPart targetSwtBotPart = editor.getEditPart(CONTAINER_TO_DRAG_P2, AbstractDiagramContainerEditPart.class); final IGraphicalEditPart targetPart = (IGraphicalEditPart) targetSwtBotPart.part(); Point targetCenter = targetPart.getFigure().getBounds().getCenter(); editor.drag(c1Location, targetCenter); assertEquals("An error message was generated !", rowCount, errorLogBot.tree().rowCount()); } finally { closeErrorLogView(); } }
Source:
<code>void testPreCanUnlockResearchEvent() throws InterruptedException { SlimefunPlugin.getRegistry().setResearchingEnabled(true); NamespacedKey key = new NamespacedKey(plugin, "simple_research"); Research research = new Research(key, 250, "Test", 10); research.register(); SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class); Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItem(Material.TORCH, "&bResearch Test")); <START> research.guideClickInteraction(guide,player,profile,sfItem,sfItem.getCategory(),0); <END> server.getPluginManager().assertEventFired(PreCanUnlockResearchEvent.class, event -> { Assertions.assertEquals(player, event.getPlayer()); Assertions.assertEquals(research, event.getResearch()); Assertions.assertEquals(sfItem,event.getSlimefunItem()); Assertions.assertFalse(event.isCancelled()); return true; }); }</code><technical_language>Formatting. suggestion research.guideClickInteraction(guide, player, profile, sfItem, sfItem.getCategory(), 0);</technical_language>

Target:
void testPreCanUnlockResearchEvent() throws InterruptedException { SlimefunPlugin.getRegistry().setResearchingEnabled(true); NamespacedKey key = new NamespacedKey(plugin, "simple_research"); Research research = new Research(key, 250, "Test", 10); research.register(); SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class); Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItem(Material.TORCH, "&bResearch Test")); research.unlockFromGuide(guide, player, profile, sfItem, sfItem.getCategory(), 0); server.getPluginManager().assertEventFired(PlayerPreResearchEvent.class, event -> { Assertions.assertEquals(player, event.getPlayer()); Assertions.assertEquals(research, event.getResearch()); Assertions.assertEquals(sfItem, event.getSlimefunItem()); Assertions.assertFalse(event.isCancelled()); return true; }); }
Source:
<code>public void testCreateSecret() throws Exception { requireDockerApiVersionAtLeast("1.25", "swarm support"); <START> final String secretData = Base64.encodeAsString("testdata".getBytes()); <END> final SecretSpec secret = SecretSpec.builder().name("asecret").data(secretData).build(); final SecretCreateResponse response = sut.createSecret(secret); assertThat(response.id(), is(notNullValue())); }</code><technical_language>test data Base64-url-safe-encoded, labels, collision existing secret, etc</technical_language>

Target:
public void testCreateSecret() throws Exception { requireDockerApiVersionAtLeast("1.25", "swarm support"); final String secretData = Base64.encodeAsString("testdata".getBytes()); HashMap<String, String> labels = new HashMap<>(); labels.put("foo", "bar"); labels.put("1", "a"); final SecretSpec secret1 = SecretSpec.builder().name("asecret").data(secretData) .labels(labels).build(); final SecretCreateResponse response1 = sut.createSecret(secret1); assertThat(response1.id(), is(notNullValue())); final SecretSpec secret2Conflict = SecretSpec.builder().name("asecret").data(secretData) .labels(labels).build(); try { sut.createSecret(secret2Conflict); fail("Should fail due to secret name conflict"); } catch (ConflictException de) final SecretSpec secret3PlainData = SecretSpec.builder().name("asecret2").data("plainData") .labels(labels).build(); try { sut.createSecret(secret3PlainData); fail("Should fail due to plain data"); } catch (DockerException de) }