auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
void apply(RequestBuilder builder, @Nullable Map<String, T> value) throws IOException { if (value == null) { throw Utils.parameterError(method, p, "Query map was null"); } boolean fail = false; String entryKey = null; T entryValue = null; for (Map.Entry<String, T> entry : value.entrySet()) { entryKey = entry.getKey(); if (entryKey == null) { throw Utils.parameterError(method, p, "Query map contained null key."); } entryValue = entry.getValue(); if (entryValue == null) { throw Utils.parameterError( method, p, "Query map contained null value for key '" + entryKey + "'."); } String convertedEntryValue; if (entryValue instanceof List || entryValue.getClass().isArray()) { List<String> list = null; if (entryValue.getClass().isArray()) { throw new UnsupportedOperationException(); } if (entryValue instanceof List) { list = (List<String>) entryValue; } Iterator i = list.iterator(); if (!i.hasNext()) { throw new IllegalArgumentException(); } convertedEntryValue = valueConverter.convert((T) i.next()); if (convertedEntryValue == null) { fail = true; break; } else { builder.addQueryParam(entryKey, convertedEntryValue, encoded); } while (i.hasNext()) { convertedEntryValue = valueConverter.convert((T) i.next()); if (convertedEntryValue == null) { fail = true; break; } else { builder.addQueryParam(entryKey, convertedEntryValue, encoded); } } } else { convertedEntryValue = valueConverter.convert(entryValue); if (convertedEntryValue == null) { fail = true; break; } else { builder.addQueryParam(entryKey, convertedEntryValue, encoded); } } } if (fail) { throw Utils.parameterError( method, p, "Query map value '" + entryValue + "' converted to null by " + valueConverter.getClass().getName() + " for key '" + entryKey + "'."); } }

Target:
void apply(RequestBuilder builder, @Nullable Map<String, T> value) throws IOException { if (value == null) { throw Utils.parameterError(method, p, "Query map was null"); } boolean fail = false; String entryKey = null; T entryValue = null; for (Map.Entry<String, T> entry : value.entrySet()) { entryKey = entry.getKey(); if (entryKey == null) { throw Utils.parameterError(method, p, "Query map contained null key."); } entryValue = entry.getValue(); if (entryValue == null) { throw Utils.parameterError( method, p, "Query map contained null value for key '" + entryKey + "'."); } String convertedEntryValue; if (entryValue instanceof Iterable) { Iterator i = ((Iterable) entryValue).iterator(); while (i.hasNext()) { Object t = i.next(); if (t == null) { fail = true; break; } else { convertedEntryValue = valueConverter.convert((T) t); builder.addQueryParam(entryKey, convertedEntryValue, encoded); } } } else { convertedEntryValue = valueConverter.convert(entryValue); if (convertedEntryValue == null) { fail = true; break; } else { builder.addQueryParam(entryKey, convertedEntryValue, encoded); } } } if (fail) { throw Utils.parameterError( method, p, "Query map value '" + entryValue + "' converted to null by " + valueConverter.getClass().getName() + " for key '" + entryKey + "'."); } }
Source:
private void deeplyPrint(IStatus status, PrintStream strm, int level) { appendLevelPrefix(strm, level); String msg = status.getMessage(); strm.println(msg); Throwable cause = status.getException(); if (cause != null) { strm.print("Caused by: "); if (stackTrace || !(msg.equals(cause.getMessage()) || msg.equals(cause.toString()))) deeplyPrint(cause, strm, level); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (IStatus children1 : children) { deeplyPrint(children1, strm, level + 1); } } }

Target:
private void deeplyPrint(IStatus status, PrintStream strm, int level) { appendLevelPrefix(strm, level); String msg = status.getMessage(); strm.println(msg); Throwable cause = status.getException(); if (cause != null) { strm.print("Caused by: "); if (stackTrace || !(msg.equals(cause.getMessage()) || msg.equals(cause.toString()))) deeplyPrint(cause, strm, level); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (IStatus child : children) { deeplyPrint(child, strm, level + 1); } } }
Source:
public RestRequest makeRequest(int method, String url, java.util.Map<String, String> params, RestRequest.Listener listener, RestRequest.ErrorListener errorListener) { AppLog.v(T.TESTS, this.getClass() + ": makeRequest(" + url + ")"); RestRequest dummyReturnValue = new RestRequest(method, url, params, listener, errorListener); String filename = mPrefix + "-" + url.replace("https://", "").replace("/", "-").replace(".", "-").replace("?", "-") + ".json"; if ("password-invalid".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } if ("username-exists".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } if ("timeout".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyTimeoutError()); return dummyReturnValue; } if ("site-reserved".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } String data = fileToString(filename); if (data == null) { AppLog.e(T.TESTS, "Can't read file: " + filename); if (errorListener != null) { errorListener.onErrorResponse(new VolleyError("Can't read file: " + filename)); } return dummyReturnValue; } try { JSONObject jsonObj = new JSONObject(data); listener.onResponse(jsonObj); } catch (JSONException je) { AppLog.e(T.TESTS, je.toString()); } return dummyReturnValue; }

Target:
public RestRequest makeRequest(int method, String url, java.util.Map<String, String> params, RestRequest.Listener listener, RestRequest.ErrorListener errorListener) { AppLog.v(T.TESTS, this.getClass() + ": makeRequest(" + url + ")"); RestRequest dummyReturnValue = new RestRequest(method, url, params, listener, errorListener); String filename = mPrefix + "-" + url.replace("https://", "").replace("/", "-").replace(".", "-").replace("?", "-") + ".json"; if ("password-invalid".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } if ("username-exists".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } if ("timeout".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyTimeoutError()); return dummyReturnValue; } if ("site-reserved".equals(mPrefix) && errorListener != null) { errorListener.onErrorResponse(forgeVolleyErrorFromFilename(filename)); return dummyReturnValue; } String data = fileToString(filename); if (data == null) { AppLog.e(T.TESTS, "Can't read file: " + filename); throw new RuntimeException("Can't read file: " + filename); } try { JSONObject jsonObj = new JSONObject(data); listener.onResponse(jsonObj); } catch (JSONException je) { AppLog.e(T.TESTS, je.toString()); } return dummyReturnValue; }
Source:
public ExecutionResult execute(Project project) { ProjectPreferenceManager projectPrefManager = new ProjectPreferenceManager(project, RepositoryPlugin.PLUGIN_ID, false); final String prjKey = "repository.project.id"; final String prodKey = "product.date.id"; final String value = projectPrefManager.getValue(prjKey); if (StringUtils.isBlank(value)) { String v = System.getProperty(prodKey, String.valueOf(System.currentTimeMillis())); projectPrefManager.setValue(prjKey, StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.MIGRATION_TOKEN).encrypt(v)); projectPrefManager.save(); return ExecutionResult.SUCCESS_NO_ALERT; } return ExecutionResult.NOTHING_TO_DO; }

Target:
public ExecutionResult execute(Project project) { ProjectPreferenceManager projectPrefManager = new ProjectPreferenceManager(project, RepositoryPlugin.PLUGIN_ID, false); final String prjKey = "repository.project.id"; final String prodKey = "product.date.id"; final String value = projectPrefManager.getValue(prjKey); if (StringUtils.isBlank(value)) { String v = System.getProperty(prodKey, String.valueOf(System.currentTimeMillis())); projectPrefManager.setValue(prjKey, CryptoMigrationUtil.encrypt(v)); projectPrefManager.save(); return ExecutionResult.SUCCESS_NO_ALERT; } return ExecutionResult.NOTHING_TO_DO; }
Source:
private void parseOtherAlg(final OtherAlgorithm other) throws TypeImportException, XMLStreamException { String language = getAttributeValue(LibraryElementTags.LANGUAGE_ATTRIBUTE); if (language != null) { other.setLanguage(language); } else { throw new TypeImportException(Messages.FBTImporter_OTHER_ALG_MISSING_LANG_EXCEPTION); } String text = getAttributeValue(LibraryElementTags.TEXT_ATTRIBUTE); if (text != null) { other.setText(text); } else { throw new TypeImportException(Messages.FBTImporter_OTHER_ALG_MISSING_TEXT_EXCEPTION); } proceedToEndElementNamed(LibraryElementTags.OTHER_ELEMENT); }

Target:
private void parseOtherAlg(final OtherAlgorithm other) throws TypeImportException, XMLStreamException { String language = getAttributeValue(LibraryElementTags.LANGUAGE_ATTRIBUTE); if (null != language) { other.setLanguage(language); } else { throw new TypeImportException(Messages.FBTImporter_OTHER_ALG_MISSING_LANG_EXCEPTION); } String text = getAttributeValue(LibraryElementTags.TEXT_ATTRIBUTE); if (null != text) { other.setText(text); } else { throw new TypeImportException(Messages.FBTImporter_OTHER_ALG_MISSING_TEXT_EXCEPTION); } proceedToEndElementNamed(LibraryElementTags.OTHER_ELEMENT); }
Source:
public boolean isStop() { if (this.scannerParam.getMaxScanDurationInMins() > 0) { if (System.currentTimeMillis() - this.hostProcessStartTime > TimeUnit.MINUTES.toMillis(this.scannerParam.getMaxScanDurationInMins())) { return true; } } return (isStop || parentScanner.isStop()); }

Target:
public boolean isStop() { if (this.scannerParam.getMaxScanDurationInMins() > 0) { if (System.currentTimeMillis() - this.hostProcessStartTime > TimeUnit.MINUTES.toMillis(this.scannerParam.getMaxScanDurationInMins())) { this.stopReason = Constant.messages.getString("ascan.progress.label.skipped.reason.maxScan"); this.stop(); } } return (isStop || parentScanner.isStop()); }
Source:
private void setTripDetails(ObaTripDetailsResponse data) { mTripInfo = data; final int code = mTripInfo.getCode(); if (code == ObaApi.OBA_OK) { setEmptyText(""); } else { setEmptyText(UIHelp.getRouteErrorString(getActivity(), code)); return; } setUpHeader(); mAdapter = new TripDetailsAdapter(); setListAdapater(mAdapter); if (mStopId != null) { final int stopIndex = findIndexForStop(mTripInfo.getSchedule().getStopTimes(), mStopId); if (stopIndex != -1) { final ListView listView = getListView(); listView.post(new Runnable() { @Override public void run() { listView.smoothScrollToPosition(stopIndex); } }); } } }

Target:
private void setTripDetails(ObaTripDetailsResponse data) { mTripInfo = data; final int code = mTripInfo.getCode(); if (code == ObaApi.OBA_OK) { setEmptyText(""); } else { setEmptyText(UIHelp.getRouteErrorString(getActivity(), code)); return; } setUpHeader(); final ListView listView = getListView(); if (mAdapter == null) { mAdapter = new TripDetailsAdapter(); setListAdapater(mAdapter); if (mStopId != null) { final int stopIndex = findIndexForStop(mTripInfo.getSchedule().getStopTimes(), mStopId); if (stopIndex != -1) { listView.post(new Runnable() { @Override public void run() { listView.setSelection(stopIndex); } }); } } } else { int index = listView.getFirstVisiblePosition(); View v = listView.getChildAt(0); int top = (v == null) ? 0 : v.getTop(); mAdapter.notifyDataSetChanged(); listView.setSelectionFromTop(index, top); } }
Source:
public void execute() { if (this.outputFile == null) { throw new BuildException("outputFile attribute must be set"); } Compiler.setLoggingLevel(Level.OFF); CompilerOptions options = createCompilerOptions(); Compiler compiler = createCompiler(options); List<SourceFile> externs = findExternFiles(options); List<SourceFile> sources = findSourceFiles(); if (isStale() || forceRecompile) { log("Compiling " + sources.size() + " file(s) with " + externs.size() + " extern(s)"); Result result = compiler.compile(externs, sources, options); if (result.success) { StringBuilder source = new StringBuilder(compiler.toSource()); if (this.outputWrapperFile != null) { try { this.outputWrapper = Files.toString(this.outputWrapperFile, UTF_8); } catch (Exception e) { throw new BuildException("Invalid output_wrapper_file specified."); } } if (this.outputWrapper != null) { int pos = -1; pos = this.outputWrapper.indexOf(CommandLineRunner.OUTPUT_MARKER); if (pos > -1) { String prefix = this.outputWrapper.substring(0, pos); source.insert(0, prefix); int suffixStart = pos + CommandLineRunner.OUTPUT_MARKER.length(); String suffix = this.outputWrapper.substring(suffixStart); source.append(suffix); } else { throw new BuildException("Invalid output_wrapper specified. " + "Missing '" + CommandLineRunner.OUTPUT_MARKER + "'."); } } else { source.append(System.getProperty("line.separator")); source.append(" } if (result.sourceMap != null) { flushSourceMap(result.sourceMap); } writeResult(source.toString()); } else { throw new BuildException("Compilation failed."); } } else { log("None of the files changed. Compilation skipped."); } }

Target:
public void execute() { if (this.outputFile == null) { throw new BuildException("outputFile attribute must be set"); } Compiler.setLoggingLevel(Level.OFF); CompilerOptions options = createCompilerOptions(); Compiler compiler = createCompiler(options); List<SourceFile> externs = findExternFiles(options); List<SourceFile> sources = findSourceFiles(); if (isStale() || forceRecompile) { log("Compiling " + sources.size() + " file(s) with " + externs.size() + " extern(s)"); Result result = compiler.compile(externs, sources, options); if (result.success) { StringBuilder source = new StringBuilder(compiler.toSource()); if (this.outputWrapperFile != null) { try { this.outputWrapper = Files.toString(this.outputWrapperFile, UTF_8); } catch (Exception e) { throw new BuildException("Invalid output_wrapper_file specified."); } } if (this.outputWrapper != null) { int pos = -1; pos = this.outputWrapper.indexOf(CommandLineRunner.OUTPUT_MARKER); if (pos > -1) { String prefix = this.outputWrapper.substring(0, pos); source.insert(0, prefix); int suffixStart = pos + CommandLineRunner.OUTPUT_MARKER.length(); String suffix = this.outputWrapper.substring(suffixStart); source.append(suffix); } else { throw new BuildException("Invalid output_wrapper specified. " + "Missing '" + CommandLineRunner.OUTPUT_MARKER + "'."); } } if (result.sourceMap != null) { flushSourceMap(result.sourceMap); } writeResult(source.toString()); } else { throw new BuildException("Compilation failed."); } } else { log("None of the files changed. Compilation skipped."); } }
Source:
public void null_key_should_throw_NPE() { underTest = new AnalysisPropertyDto(); expectedException.expect(NullPointerException.class); underTest.setKey(null); }

Target:
public void null_key_should_throw_NPE() { underTest = new AnalysisPropertyDto(); expectedException.expect(NullPointerException.class); expectedException.expectMessage("key cannot be null"); underTest.setKey(null); }
Source:
public DiskQuotaConfig loadConfig() throws IOException, ConfigurationException { DiskQuotaConfig quotaConfig; InputStream configIn; if (resourceProvider.hasInput()) { try{ configIn = resourceProvider.in(); } catch (IOException e) { configIn = null; } } else { configIn = null; } if (configIn != null) { log.info("Quota config is: " + resourceProvider.getLocation()); try { quotaConfig = loadConfiguration(configIn); if (null == quotaConfig) { throw new ConfigurationException("Couldn't parse configuration file " + resourceProvider.getLocation()); } } catch (RuntimeException e) { log.error( "Error loading DiskQuota configuration from " + resourceProvider.getLocation() + ": " + e.getMessage() + ". Deferring to a default (disabled) configuration", e); quotaConfig = new DiskQuotaConfig(); } finally { configIn.close(); } } else { log.info("DiskQuota configuration could not be read: " + resourceProvider.getLocation()); quotaConfig = new DiskQuotaConfig(); } quotaConfig.setDefaults(); validateConfig(quotaConfig); return quotaConfig; }

Target:
public DiskQuotaConfig loadConfig() throws IOException, ConfigurationException { DiskQuotaConfig quotaConfig = null; if (resourceProvider.hasInput()) { log.info("Quota config is: " + resourceProvider.getLocation()); try (InputStream configIn = resourceProvider.in()) { quotaConfig = loadConfiguration(configIn); if (null == quotaConfig) { throw new ConfigurationException("Couldn't parse configuration file " + resourceProvider.getLocation()); } } catch (IOException | RuntimeException e) { log.error( "Error loading DiskQuota configuration from " + resourceProvider.getLocation() + ": " + e.getMessage() + ". Deferring to a default (disabled) configuration", e); } } else { log.info("DiskQuota configuration is not readable: " + resourceProvider.getLocation()); } if (quotaConfig == null) { quotaConfig = new DiskQuotaConfig(); } quotaConfig.setDefaults(); validateConfig(quotaConfig); return quotaConfig; }
Source:
public void handle(SyncGroupResponse syncResponse, RequestFuture<ByteBuffer> future) { Errors error = syncResponse.error(); if (error == Errors.NONE) { sensors.syncLatency.record(response.requestLatencyMs()); future.complete(ByteBuffer.wrap(syncResponse.data.assignment())); } else { requestRejoin(); if (error == Errors.GROUP_AUTHORIZATION_FAILED) { future.raise(new GroupAuthorizationException(rebalanceConfig.groupId)); } else if (error == Errors.REBALANCE_IN_PROGRESS) { log.debug("SyncGroup failed because the group began another rebalance"); future.raise(error); } else if (error == Errors.FENCED_INSTANCE_ID) { log.error("Received fatal exception: group.instance.id gets fenced"); future.raise(error); } else if (error == Errors.UNKNOWN_MEMBER_ID || error == Errors.ILLEGAL_GENERATION) { log.debug("SyncGroup failed: {}", error.message()); resetGeneration(this.getClass().getName() + " encountering " + error); future.raise(error); } else if (error == Errors.COORDINATOR_NOT_AVAILABLE || error == Errors.NOT_COORDINATOR) { log.debug("SyncGroup failed: {}", error.message()); markCoordinatorUnknown(); future.raise(error); } else { future.raise(new KafkaException("Unexpected error from SyncGroup: " + error.message())); } } }

Target:
public void handle(SyncGroupResponse syncResponse, RequestFuture<ByteBuffer> future) { Errors error = syncResponse.error(); if (error == Errors.NONE) { sensors.syncLatency.record(response.requestLatencyMs()); future.complete(ByteBuffer.wrap(syncResponse.data.assignment())); } else { requestRejoin(); if (error == Errors.GROUP_AUTHORIZATION_FAILED) { future.raise(GroupAuthorizationException.forGroupId(rebalanceConfig.groupId)); } else if (error == Errors.REBALANCE_IN_PROGRESS) { log.debug("SyncGroup failed because the group began another rebalance"); future.raise(error); } else if (error == Errors.FENCED_INSTANCE_ID) { log.error("Received fatal exception: group.instance.id gets fenced"); future.raise(error); } else if (error == Errors.UNKNOWN_MEMBER_ID || error == Errors.ILLEGAL_GENERATION) { log.debug("SyncGroup failed: {}", error.message()); resetGeneration(); future.raise(error); } else if (error == Errors.COORDINATOR_NOT_AVAILABLE || error == Errors.NOT_COORDINATOR) { log.debug("SyncGroup failed: {}", error.message()); markCoordinatorUnknown(); future.raise(error); } else { future.raise(new KafkaException("Unexpected error from SyncGroup: " + error.message())); } } }
Source:
protected void initSelectedType() { final VmInterfaceType defaultNicType = getDeafultNicTypeByProfile(); final Collection<VmInterfaceType> vnicTypes = supportedVnicTypes == null ? new ArrayList<VmInterfaceType>() : supportedVnicTypes; if (getNicType().getItems() != vnicTypes) { getNicType().setItems(vnicTypes, defaultNicType); } else { getNicType().setSelectedItem(defaultNicType); } }

Target:
protected void initSelectedType() { final VmInterfaceType defaultNicType = getDeafultNicTypeByProfile(); final Collection<VmInterfaceType> vnicTypes = supportedVnicTypes == null ? new ArrayList<VmInterfaceType>() : supportedVnicTypes; if (getNicType().getItems() == null) { getNicType().setItems(vnicTypes, defaultNicType); } else { getNicType().setSelectedItem(defaultNicType); } }
Source:
public void testDynamicImportSpecifier() { testTypes( "var foo = undefined; import(foo);", "dynamic import specifier\n" + "found : undefined\n" + "required: string"); }

Target:
public void testDynamicImportSpecifier() { testTypes( "var foo = undefined; import(foo);", lines("dynamic import specifier", "found : undefined", "required: string")); }
Source:
private SSAInstruction[] makeStatements(IClass klass) { assert klass != null; ArrayList<SSAInstruction> statements = new ArrayList<>(); int nextLocal = 2; int retValue = nextLocal++; NewSiteReference ref = NewSiteReference.make(NEW_PC, klass.getReference()); SSANewInstruction N = null; if (klass.isArrayClass()) { int length = nextLocal++; statements.add(insts.ArrayLengthInstruction(statements.size(), length, 1)); int[] sizes = new int[((ArrayClass) klass).getDimensionality()]; Arrays.fill(sizes, length); N = insts.NewInstruction(statements.size(), retValue, ref, sizes); } else { N = insts.NewInstruction(statements.size(), retValue, ref); } statements.add(N); int exceptionValue = nextLocal++; if (klass.getReference().isArrayType()) { int[] params = new int[2]; params[0] = 1; params[1] = retValue; SSAInvokeInstruction S = insts.InvokeInstruction(statements.size(), params, exceptionValue, ARRAYCOPY_SITE, null); statements.add(S); } else { IClass k = klass; while (k != null) { for (IField f : klass.getDeclaredInstanceFields()) { int tempValue = nextLocal++; SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference()); statements.add(G); SSAPutInstruction P = insts.PutInstruction(statements.size(), retValue, tempValue, f.getReference()); statements.add(P); } k = k.getSuperclass(); } } SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false); statements.add(R); SSAInstruction[] result = new SSAInstruction[statements.size()]; Iterator<SSAInstruction> it = statements.iterator(); Arrays.setAll(result, i -> it.next()); return result; }

Target:
private SSAInstruction[] makeStatements(IClass klass) { assert klass != null; ArrayList<SSAInstruction> statements = new ArrayList<>(); int nextLocal = 2; int retValue = nextLocal++; NewSiteReference ref = NewSiteReference.make(NEW_PC, klass.getReference()); SSANewInstruction N = null; if (klass.isArrayClass()) { int length = nextLocal++; statements.add(insts.ArrayLengthInstruction(statements.size(), length, 1)); int[] sizes = new int[((ArrayClass) klass).getDimensionality()]; Arrays.fill(sizes, length); N = insts.NewInstruction(statements.size(), retValue, ref, sizes); } else { N = insts.NewInstruction(statements.size(), retValue, ref); } statements.add(N); int exceptionValue = nextLocal++; if (klass.getReference().isArrayType()) { int[] params = new int[2]; params[0] = 1; params[1] = retValue; SSAInvokeInstruction S = insts.InvokeInstruction(statements.size(), params, exceptionValue, ARRAYCOPY_SITE, null); statements.add(S); } else { IClass k = klass; while (k != null) { for (IField f : klass.getDeclaredInstanceFields()) { int tempValue = nextLocal++; SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference()); statements.add(G); SSAPutInstruction P = insts.PutInstruction(statements.size(), retValue, tempValue, f.getReference()); statements.add(P); } k = k.getSuperclass(); } } SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false); statements.add(R); return statements.toArray(new SSAInstruction[0]); }
Source:
public void copyNodeWithEmptyMultiValueProperty() throws Exception { String configuration = "{\"indexProviders\": {\n" + " \"local\": {\n" + " \"classname\": \"org.modeshape.jcr.index.local.LocalIndexProvider\",\n" + " \"directory\": \"target/1234/indexes\"\n" + " }\n" + " },\n" + " \"indexes\": {\n" + " \"nodeTypes\": {\n" + " \"kind\": \"nodeType\",\n" + " \"provider\": \"local\",\n" + " \"synchronous\": \"true\",\n" + " \"nodeType\": \"nt:base\",\n" + " \"columns\": \"jcr:primaryType(STRING)\"\n" + " }}}"; startRepositoryWithConfiguration(configuration); session.getRootNode().addNode("a"); Node node = session.getNode("/a"); node.addMixin("mix:referenceable"); session.save(); node.removeMixin("mix:referenceable"); session.save(); assertTrue(node.hasProperty("jcr:mixinTypes")); assertThat(node.getProperty("jcr:mixinTypes").getValues().length, is(0)); session.getWorkspace().copy(session.getNode("/a").getPath(), "/a2"); session.save(); }

Target:
public void copyNodeWithEmptyMultiValueProperty() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-local-provider-and-nodetype-index.json"); session.getRootNode().addNode("a"); Node node = session.getNode("/a"); node.addMixin("mix:referenceable"); session.save(); node.removeMixin("mix:referenceable"); session.save(); assertTrue(node.hasProperty("jcr:mixinTypes")); assertThat(node.getProperty("jcr:mixinTypes").getValues().length, is(0)); session.getWorkspace().copy(session.getNode("/a").getPath(), "/a2"); session.save(); }
Source:
public String promptForExternalConfiguration() { SystemAccess.Console console = system.console(); console.format("WARNING: Please ensure that you have made backups of the directory [%s] before proceeding.\n", niogitDir); Collection<String> validResponses = Arrays.asList("yes", "no"); String response; do { response = console.readLine("Do you want provide a path to an external Pom migration json with dependencies and repositories ? [yes/no]: ").toLowerCase(); } while (!validResponses.contains(response)); if("yes".equals(response)){ do { response = console.readLine("Please insert the path to folder containing the pom-migration.json file : ").trim(); } while (!response.equals("") && !jsonExists(response)); return response + "/" + JSON_POM_FILE; }else{ return ""; } }

Target:
public String promptForExternalConfiguration() { SystemAccess.Console console = system.console(); Collection<String> validResponses = Arrays.asList("yes", "no"); String response; do { response = console.readLine("Do you want provide a path to an external Pom migration json with dependencies and repositories ? [yes/no]: ").toLowerCase(); } while (!validResponses.contains(response)); if ("yes".equals(response)) { boolean valid = false; response = console.readLine("Please provide the path to folder containing the pom-migration.json file : ").trim(); do { if (!jsonExists(response)) { response = console.readLine("The file pom-migration.json doesn't exist in the directory you provided. Please try again :").trim(); } else { valid = true; } } while (response != null && !valid); return response + File.separator + JSON_POM_FILE; } else { return ""; } }
Source:
private static StringBuilder getStringBuilder() { StringBuilder sb = TL_STRING_BUILDER.get(); sb.setLength(0); return sb; }

Target:
protected static StringBuilder getStringBuilder() { StringBuilder sb = TL_STRING_BUILDER.get(); sb.setLength(0); return sb; }
Source:
private SlotManagerBuilder() { this.slotMatchingStrategy = AnyMatchingSlotMatchingStrategy.INSTANCE; this.scheduledExecutor = TestingUtils.defaultScheduledExecutor(); this.taskManagerRequestTimeout = TestingUtils.infiniteTime(); this.slotRequestTimeout = TestingUtils.infiniteTime(); this.taskManagerTimeout = TestingUtils.infiniteTime(); this.maxSlotNum = Integer.MAX_VALUE; this.waitResultConsumedBeforeRelease = true; }

Target:
private SlotManagerBuilder() { this.slotMatchingStrategy = AnyMatchingSlotMatchingStrategy.INSTANCE; this.scheduledExecutor = TestingUtils.defaultScheduledExecutor(); this.taskManagerRequestTimeout = TestingUtils.infiniteTime(); this.slotRequestTimeout = TestingUtils.infiniteTime(); this.taskManagerTimeout = TestingUtils.infiniteTime(); this.waitResultConsumedBeforeRelease = true; this.defaultWorkerResourceSpec = WorkerResourceSpec.ZERO; this.numSlotsPerWorker = 1; this.slotManagerMetricGroup = UnregisteredMetricGroups.createUnregisteredSlotManagerMetricGroup(); this.maxSlotNum = ResourceManagerOptions.MAX_SLOT_NUM.defaultValue(); }
Source:
public void bindFieldPrimitiveValues() throws SQLException { int index = ThreadLocalRandom.current().nextInt(); verifyBindField(++index, Schema.INT8_SCHEMA, (byte) 42).setByte(index, (byte) 42); verifyBindField(++index, Schema.INT16_SCHEMA, (short) 42).setShort(index, (short) 42); verifyBindField(++index, Schema.INT32_SCHEMA, 42).setInt(index, 42); verifyBindField(++index, Schema.INT64_SCHEMA, 42L).setLong(index, 42L); verifyBindField(++index, Schema.BOOLEAN_SCHEMA, false).setBoolean(index, false); verifyBindField(++index, Schema.BOOLEAN_SCHEMA, true).setBoolean(index, true); verifyBindField(++index, Schema.FLOAT32_SCHEMA, -42f).setFloat(index, -42f); verifyBindField(++index, Schema.FLOAT64_SCHEMA, 42d).setDouble(index, 42d); verifyBindField(++index, Schema.BYTES_SCHEMA, new byte[]{42}).setBytes(index, new byte[]{42}); verifyBindField(++index, Schema.BYTES_SCHEMA, ByteBuffer.wrap(new byte[]{42})).setBytes(index, new byte[]{42}); verifyBindField(++index, Schema.STRING_SCHEMA, "yep").setString(index, "yep"); }

Target:
public void bindFieldPrimitiveValues() throws SQLException { int index = ThreadLocalRandom.current().nextInt(); verifyBindField(++index, Schema.INT8_SCHEMA, (byte) 42).setByte(index, (byte) 42); verifyBindField(++index, Schema.INT16_SCHEMA, (short) 42).setShort(index, (short) 42); verifyBindField(++index, Schema.INT32_SCHEMA, 42).setInt(index, 42); verifyBindField(++index, Schema.INT64_SCHEMA, 42L).setLong(index, 42L); verifyBindField(++index, Schema.BOOLEAN_SCHEMA, false).setBoolean(index, false); verifyBindField(++index, Schema.BOOLEAN_SCHEMA, true).setBoolean(index, true); verifyBindField(++index, Schema.FLOAT32_SCHEMA, -42f).setFloat(index, -42f); verifyBindField(++index, Schema.FLOAT64_SCHEMA, 42d).setDouble(index, 42d); verifyBindField(++index, Schema.BYTES_SCHEMA, new byte[]{42}).setBytes(index, new byte[]{42}); verifyBindField(++index, Schema.BYTES_SCHEMA, ByteBuffer.wrap(new byte[]{42})).setBytes(index, new byte[]{42}); verifyBindField(++index, Schema.STRING_SCHEMA, "yep").setString(index, "yep"); verifyBindField(++index, Decimal.schema(0), new BigDecimal("1.5").setScale(0, BigDecimal.ROUND_HALF_EVEN)).setBytes(index, new byte[]{2}); verifyBindField(++index, Date.SCHEMA, new java.util.Date(0)).setInt(index, 0); verifyBindField(++index, Time.SCHEMA, new java.util.Date(1000)).setInt(index, 1000); verifyBindField(++index, Timestamp.SCHEMA, new java.util.Date(100)).setLong(index, 100); }
Source:
private static Iterable<IMarkerEvent> getMarkers(TimeGraphControl timeGraphControl, ITimeGraphEntry entry, Point pt) { List<IMarkerEvent> markers = timeGraphControl.getMarkers(); List<IMarkerEvent> retVal = new ArrayList<>(); if (markers != null) { int height = Math.max(timeGraphControl.getItemHeight(), 10) / 2; long fuzzStart = timeGraphControl.getTimeAtX(pt.x - height); long fuzzEnd = timeGraphControl.getTimeAtX(pt.x + height); for (IMarkerEvent marker : markers) { if (Objects.equals(marker.getEntry(), entry)) { long duration = marker.getDuration(); long startTime = marker.getTime(); long endTime = startTime + duration; if ((startTime < fuzzEnd) && (endTime > fuzzStart)) { retVal.add(marker); } } } } return retVal; }

Target:
private static Iterable<IMarkerEvent> getMarkers(TimeGraphControl timeGraphControl, ITimeGraphEntry entry, Point pt) { List<IMarkerEvent> markers = timeGraphControl.getMarkers(); List<IMarkerEvent> retVal = new ArrayList<>(); if (markers != null) { int fuzz = 5; long fuzzStart = timeGraphControl.getTimeAtX(pt.x - fuzz); long fuzzEnd = timeGraphControl.getTimeAtX(pt.x + fuzz); for (IMarkerEvent marker : markers) { if (Objects.equals(marker.getEntry(), entry)) { long duration = marker.getDuration(); long startTime = marker.getTime(); long endTime = startTime + duration; if ((startTime < fuzzEnd) && (endTime > fuzzStart)) { retVal.add(marker); } } } } return retVal; }
Source:
protected void completeInitiatingFuture(boolean deploy, IgniteUuid reqSrvcId, Throwable err) { GridFutureAdapter<?> fut = deploy ? depFuts.remove(reqSrvcId) : undepFuts.remove(reqSrvcId); if (fut == null) return; if (err != null) { fut.onDone(err); if (deploy) { U.warn(log, "Failed to deploy service, cfg=" + ((GridServiceDeploymentFuture)fut).configuration(), err); } else U.warn(log, "Failed to undeploy service, srvcId=" + reqSrvcId, err); } else fut.onDone(); }

Target:
void completeInitiatingFuture(boolean deploy, IgniteUuid reqSrvcId, Throwable err) { GridFutureAdapter<?> fut = deploy ? depFuts.remove(reqSrvcId) : undepFuts.remove(reqSrvcId); if (fut == null) return; if (err != null) { fut.onDone(err); if (deploy) { U.warn(log, "Failed to deploy service, cfg=" + ((GridServiceDeploymentFuture)fut).configuration(), err); } else U.warn(log, "Failed to undeploy service, srvcId=" + reqSrvcId, err); } else fut.onDone(); }
Source:
public boolean isSameType(IType type) { if (type == this) return true; if (type instanceof ITypedef) return type.isSameType(this); ICPPClassTemplate classTemplate = getClassTemplate(); if (type instanceof ICPPDeferredClassInstance) { final ICPPDeferredClassInstance rhs = (ICPPDeferredClassInstance) type; if (!classTemplate.isSameType((IType) rhs.getSpecializedBinding())) return false; return CPPTemplates.haveSameArguments(this, rhs); } else if (type instanceof PDOMCPPClassTemplate) { return classTemplate == type; } return false; }

Target:
public boolean isSameType(IType type) { if (type == this) return true; if (type instanceof ITypedef) return type.isSameType(this); ICPPClassTemplate classTemplate = getClassTemplate(); if (type instanceof ICPPDeferredClassInstance) { final ICPPDeferredClassInstance rhs = (ICPPDeferredClassInstance) type; if (!classTemplate.isSameType((IType) rhs.getSpecializedBinding())) return false; return CPPTemplates.haveSameArguments(this, rhs); } return false; }
Source:
public Marshaller getMarshaller() throws JAXBException { if (marshaller == null) { marshaller = JAXBContext.newInstance(ServiceDefinitionsWrapper.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); } return marshaller; }

Target:
private synchronized Marshaller getMarshaller() throws JAXBException { if (marshaller == null) { marshaller = JAXBContext.newInstance(ServiceDefinitionsWrapper.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); } return marshaller; }
Source:
public StaticFunctionHandle lookupFunction(QualifiedName name, List<TypeSignatureProvider> parameterTypes) { Collection<SqlFunction> allCandidates = functions.get(name); List<SqlFunction> exactCandidates = allCandidates.stream() .filter(function -> function.getSignature().getTypeVariableConstraints().isEmpty()) .collect(Collectors.toList()); Optional<Signature> match = matchFunctionExact(exactCandidates, parameterTypes); if (match.isPresent()) { return new StaticFunctionHandle(match.get()); } List<SqlFunction> genericCandidates = allCandidates.stream() .filter(function -> !function.getSignature().getTypeVariableConstraints().isEmpty()) .collect(Collectors.toList()); match = matchFunctionExact(genericCandidates, parameterTypes); if (match.isPresent()) { return new StaticFunctionHandle(match.get()); } throw new PrestoException(FUNCTION_NOT_FOUND, constructFunctionNotFoundErrorMessage(name, parameterTypes, allCandidates)); }

Target:
public FunctionHandle lookupFunction(QualifiedName name, List<TypeSignatureProvider> parameterTypes) { Collection<SqlFunction> allCandidates = functions.get(name); List<SqlFunction> exactCandidates = allCandidates.stream() .filter(function -> function.getSignature().getTypeVariableConstraints().isEmpty()) .collect(Collectors.toList()); Optional<Signature> match = matchFunctionExact(exactCandidates, parameterTypes); if (match.isPresent()) { return new StaticFunctionHandle(match.get()); } List<SqlFunction> genericCandidates = allCandidates.stream() .filter(function -> !function.getSignature().getTypeVariableConstraints().isEmpty()) .collect(Collectors.toList()); match = matchFunctionExact(genericCandidates, parameterTypes); if (match.isPresent()) { return new StaticFunctionHandle(match.get()); } throw new PrestoException(FUNCTION_NOT_FOUND, constructFunctionNotFoundErrorMessage(name, parameterTypes, allCandidates)); }
Source:
public void testCycleGeneration() throws ParseException, IOException { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); Idl idl = new Idl(cl.getResourceAsStream("input/cycle.avdl"), "UTF-8"); Protocol protocol = idl.CompilationUnit(); String json = protocol.toString(); System.out.println(json); SpecificCompiler compiler = new SpecificCompiler(protocol); compiler.setStringType(GenericData.StringType.String); File output = new File("./target"); compiler.compileToDestination(null, output); Map<String, Schema> schemas = new HashMap<String, Schema>(); for (Schema schema : protocol.getTypes()) { final String name = schema.getName(); schemas.put(name, schema); } GenericRecordBuilder rb2 = new GenericRecordBuilder(schemas.get("SampleNode")); rb2.set("count", 10); rb2.set("subNodes", Collections.EMPTY_LIST); GenericData.Record node = rb2.build(); GenericRecordBuilder mb = new GenericRecordBuilder(schemas.get("Method")); mb.set("declaringClass", "Test"); mb.set("methodName", "test"); GenericData.Record method = mb.build(); GenericRecordBuilder spb = new GenericRecordBuilder(schemas.get("SamplePair")); spb.set("method", method); spb.set("node", node); GenericData.Record sp = spb.build(); GenericRecordBuilder rb = new GenericRecordBuilder(schemas.get("SampleNode")); rb.set("count", 10); rb.set("subNodes", Arrays.asList(sp)); GenericData.Record record = rb.build(); serDeserRecord(record); }

Target:
public void testCycleGeneration() throws ParseException, IOException { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); Idl idl = new Idl(cl.getResourceAsStream("input/cycle.avdl"), "UTF-8"); Protocol protocol = idl.CompilationUnit(); String json = protocol.toString(); LOG.info(json); SpecificCompiler compiler = new SpecificCompiler(protocol); compiler.setStringType(GenericData.StringType.String); File output = new File("./target"); compiler.compileToDestination(null, output); Map<String, Schema> schemas = new HashMap<String, Schema>(); for (Schema schema : protocol.getTypes()) { final String name = schema.getName(); schemas.put(name, schema); } GenericRecordBuilder rb2 = new GenericRecordBuilder(schemas.get("SampleNode")); rb2.set("count", 10); rb2.set("subNodes", Collections.EMPTY_LIST); GenericData.Record node = rb2.build(); GenericRecordBuilder mb = new GenericRecordBuilder(schemas.get("Method")); mb.set("declaringClass", "Test"); mb.set("methodName", "test"); GenericData.Record method = mb.build(); GenericRecordBuilder spb = new GenericRecordBuilder(schemas.get("SamplePair")); spb.set("method", method); spb.set("node", node); GenericData.Record sp = spb.build(); GenericRecordBuilder rb = new GenericRecordBuilder(schemas.get("SampleNode")); rb.set("count", 10); rb.set("subNodes", Arrays.asList(sp)); GenericData.Record record = rb.build(); serDeserRecord(record); }
Source:
public boolean isPasswordSameAsUserName(final String username) throws MiddlewareQueryException { try { if (username != null) { final Criteria criteria = this.getSession().createCriteria(User.class).add(Restrictions.eq("name", username)) .add(Restrictions.eq("password", username)); @SuppressWarnings("unchecked") final List<User> users = criteria.list(); return !users.isEmpty() ? true : false; } } catch (final HibernateException e) { this.logAndThrowException("Error with getByUsernameAndPassword(username=" + username + ") query from User: " + e.getMessage(), e); } return false; }

Target:
public boolean isPasswordSameAsUserName(final String username) throws MiddlewareQueryException { try { if (username != null) { final Criteria criteria = this.getSession().createCriteria(User.class).add(Restrictions.eq("name", username)) .add(Restrictions.eq("password", username)); @SuppressWarnings("unchecked") final List<User> users = criteria.list(); return !users.isEmpty() ? true : false; } } catch (final HibernateException e) { final String message = "Error with getByUsernameAndPassword(username=" + username + ") query from User: " + e.getMessage(); UserDAO.LOG.error(message, e); throw new MiddlewareQueryException(message, e); } return false; }
Source:
public String toString() { if (string == null) { String lineSeparator = System.lineSeparator(); StringBuilder buffer = new StringBuilder(); buffer.append("Command("); buffer.append(id); buffer.append(','); buffer.append(name == null ? "" : name); buffer.append(','); buffer.append(lineSeparator); buffer.append("\t\t"); buffer.append(description == null ? "" : description); buffer.append(','); buffer.append(lineSeparator); buffer.append("\t\t"); buffer.append(category == null ? "" : category.toString()); buffer.append(','); buffer.append(lineSeparator); buffer.append("\t\t"); buffer.append(handler == null ? "" : handler.toString()); buffer.append(','); buffer.append(lineSeparator); buffer.append("\t\t"); buffer.append(parameters == null ? "" : Arrays.toString(parameters)); buffer.append(','); buffer.append(returnType == null ? "" : returnType.toString()); buffer.append(','); buffer.append("" + defined); buffer.append(')'); string = buffer.toString(); } return string; }

Target:
public String toString() { if (string == null) { String lineSeparator = System.lineSeparator(); StringBuilder builder = new StringBuilder(); builder.append("Command("); builder.append(id); builder.append(','); builder.append(name == null ? "" : name); builder.append(','); builder.append(lineSeparator); builder.append("\t\t"); builder.append(description == null ? "" : description); builder.append(','); builder.append(lineSeparator); builder.append("\t\t"); builder.append(category == null ? "" : category.toString()); builder.append(','); builder.append(lineSeparator); builder.append("\t\t"); builder.append(handler == null ? "" : handler.toString()); builder.append(','); builder.append(lineSeparator); builder.append("\t\t"); builder.append(parameters == null ? "" : Arrays.toString(parameters)); builder.append(','); builder.append(returnType == null ? "" : returnType.toString()); builder.append(','); builder.append("" + defined); builder.append(')'); string = builder.toString(); } return string; }
Source:
protected void selectAndReveal(ISelection selection) { List<IPackageFragmentRoot> roots = new ArrayList<IPackageFragmentRoot>(); for (Object element : ((IStructuredSelection) selection).toList()) { if (element instanceof IPackageFragmentRoot) { roots.add((IPackageFragmentRoot) element); } } fProvider.handleFolderCreation(roots); super.selectAndReveal(selection); }

Target:
protected void selectAndReveal(ISelection selection) { List<IPackageFragmentRoot> roots = new ArrayList<>(); for (Object element : ((IStructuredSelection) selection).toList()) { if (element instanceof IPackageFragmentRoot) { roots.add((IPackageFragmentRoot) element); } } fProvider.handleFolderCreation(roots); super.selectAndReveal(selection); }
Source:
protected static Map<String, String> createStructFromConnection(final StorageServerConnections connection, final StoragePool storagePool) { DefaultValueMap conParams = new DefaultValueMap(); conParams.put("id", connection.getid(), Guid.Empty.toString()); conParams.put("connection", connection.getconnection(), ""); switch (connection.getstorage_type()) { case ISCSI: conParams.put("portal", connection.getportal(), ""); conParams.put("port", connection.getport(), ""); conParams.put("iqn", connection.getiqn(), ""); conParams.put("user", connection.getuser_name(), ""); conParams.put("password", connection.getpassword(), ""); break; case POSIXFS: conParams.putIfNotEmpty("mnt_options", connection.getMountOptions()); conParams.putIfNotEmpty("vfs_type", connection.getVfsType()); break; case NFS: if (storagePool == null || Config.<Boolean> getValue(ConfigValues.AdvancedNFSOptionsEnabled, storagePool.getcompatibility_version().getValue())) { if (connection.getNfsVersion() != null) { conParams.put("protocol_version", connection.getNfsVersion().getValue()); } conParams.putIfNotEmpty("timeout", connection.getNfsTimeo()); conParams.putIfNotEmpty("retrans", connection.getNfsRetrans()); } break; } return conParams; }

Target:
protected static Map<String, String> createStructFromConnection(final StorageServerConnections connection, final StoragePool storagePool) { DefaultValueMap conParams = new DefaultValueMap(); conParams.put("id", connection.getid(), Guid.Empty.toString()); conParams.put("connection", connection.getconnection(), ""); switch (connection.getstorage_type()) { case ISCSI: conParams.put("portal", connection.getportal(), ""); conParams.put("port", connection.getport(), ""); conParams.put("iqn", connection.getiqn(), ""); conParams.put("user", connection.getuser_name(), ""); conParams.put("password", connection.getpassword(), ""); break; case POSIXFS: case GLUSTERFS: conParams.putIfNotEmpty("mnt_options", connection.getMountOptions()); conParams.putIfNotEmpty("vfs_type", connection.getVfsType()); break; case NFS: if (storagePool == null || Config.<Boolean> getValue(ConfigValues.AdvancedNFSOptionsEnabled, storagePool.getcompatibility_version().getValue())) { if (connection.getNfsVersion() != null) { conParams.put("protocol_version", connection.getNfsVersion().getValue()); } conParams.putIfNotEmpty("timeout", connection.getNfsTimeo()); conParams.putIfNotEmpty("retrans", connection.getNfsRetrans()); } break; } return conParams; }
Source:
public void addCondition(ConditionExpression condition) { ConditionalEventDefinition conditionalEventDefinition = bpmn2.createConditionalEventDefinition(); FormalExpression conditionExpression = bpmn2.createFormalExpression(); String languageFormat = Scripts.scriptLanguageToUri(condition.getValue().getLanguage(), Scripts.LANGUAGE.DROOLS.format()); conditionExpression.setLanguage(languageFormat); String conditionScript = condition.getValue().getScript(); if (conditionScript != null && !conditionScript.isEmpty()) { conditionExpression.setBody(asCData(StringEscapeUtils.escapeXml10(conditionScript))); } conditionalEventDefinition.setCondition(conditionExpression); addEventDefinition(conditionalEventDefinition); }

Target:
public void addCondition(ConditionExpression condition) { ConditionalEventDefinition conditionalEventDefinition = bpmn2.createConditionalEventDefinition(); FormalExpression conditionExpression = bpmn2.createFormalExpression(); String languageFormat = Scripts.scriptLanguageToUri(condition.getValue().getLanguage(), Scripts.LANGUAGE.DROOLS.format()); conditionExpression.setLanguage(languageFormat); String conditionScript = condition.getValue().getScript(); if (conditionScript != null && !conditionScript.isEmpty()) { conditionExpression.setBody(asCData(conditionScript)); } conditionalEventDefinition.setCondition(conditionExpression); addEventDefinition(conditionalEventDefinition); }
Source:
private List<Document> toDocument(Collection<Policy> ps) { List<Document> docs = new ArrayList<Document>(); for (Policy p : ps) { try { LOGGER.trace("Policy [" + p.getId() + "] for subject [" + p.getSubject() + "]:\n" + p.getPolicy()); docs.add(Xml.toXml(p.getPolicy())); } catch (IOException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } } return docs; }

Target:
private List<Document> toDocument(Collection<Policy> ps) { List<Document> docs = new ArrayList<Document>(); for (Policy p : ps) { try { LOGGER.trace("Policy for subject [{}]: {}", p.getId(), p.getSubject(), p.getPolicy()); docs.add(Xml.toXml(p.getPolicy())); } catch (IOException | SAXException e) { throw new RuntimeException(e); } } return docs; }