auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> NatsMessage(String subject, String replyTo, ByteBuffer data, boolean utf8mode) { <END> this.subject = subject; this.replyTo = replyTo; this.data = data; if (utf8mode) { byte[] subjectBytes = subject.getBytes(StandardCharsets.UTF_8); byte[] replyBytes = (replyTo != null) ? replyTo.getBytes(StandardCharsets.UTF_8) : null; int replySize = (replyBytes != null) ? replyBytes.length + 1 : 0; this.protocolBytes = ByteBuffer.allocate(4 + subjectBytes.length + 1 + replySize + 2); protocolBytes.put((byte)'P').put((byte)'U').put((byte)'B').put((byte)' '); protocolBytes.put(subjectBytes); protocolBytes.put((byte)' '); if (replyTo != null) { protocolBytes.put(replyBytes); protocolBytes.put((byte)' '); } protocolBytes.put(String.valueOf(data.limit()).getBytes()); } else { int size = (data != null) ? data.limit() : 0; int sizeLength = fastIntLength(size); int len = 4 + subject.length() + 1 + sizeLength; if (replyTo != null) { len += replyTo.length() + 1; } this.protocolBytes = ByteBuffer.allocate(len); protocolBytes.put((byte)'P').put((byte)'U').put((byte)'B').put((byte)' '); protocolBytes.put(subject.getBytes()); protocolBytes.put((byte)' '); if (replyTo != null) { protocolBytes.put(replyTo.getBytes()); protocolBytes.put((byte)' '); } if (size > 0) { int base = protocolBytes.limit(); for (int i = size; i > 0; i /= 10) { base--; protocolBytes.put(base, (byte)(i % 10 + 0x30)); } } else { protocolBytes.put((byte)0x30); } } protocolBytes.clear(); }</code><technical_language>add PR, ok - i - i paranoid - convert 0 a byte get :-)</technical_language>

Target:
NatsMessage(String subject, String replyTo, ByteBuffer data, boolean utf8mode) { this.subject = subject; this.replyTo = replyTo; this.data = data; Charset charset; int size = (data != null) ? data.limit() : 0; int len = fastIntLength(size) + 4; if (replyTo != null) { if (utf8mode) { len += fastUtf8Length(replyTo) + 1; } else { len += replyTo.length() + 1; } } if (utf8mode) { len += fastUtf8Length(subject) + 1; charset = StandardCharsets.UTF_8; } else { len += subject.length() + 1; charset = StandardCharsets.US_ASCII; } this.protocolBytes = ByteBuffer.allocate(len); protocolBytes.put((byte)'P').put((byte)'U').put((byte)'B').put((byte)' '); protocolBytes.put(subject.getBytes(charset)); protocolBytes.put((byte)' '); if (replyTo != null) { protocolBytes.put(replyTo.getBytes(charset)); protocolBytes.put((byte)' '); } if (size > 0) { int base = protocolBytes.limit(); for (int i = size; i > 0; i /= 10) { base--; protocolBytes.put(base, (byte)(i % 10 + (byte)'0')); } } else { protocolBytes.put((byte)'0'); } protocolBytes.clear(); }
Source:
<code>synchronized SQLiteDatabase getReadableDbWithRetries() { int count = 0; while(true) { try { return getReadableDatabase(); <START> } catch (SQLiteCantOpenDatabaseException t) { <END> if (++count >= DB_OPEN_RETRY_MAX) throw t; SystemClock.sleep(count * DB_OPEN_RETRY_BACKOFF); } } }</code><technical_language>t e</technical_language>

Target:
synchronized SQLiteDatabase getReadableDbWithRetries() { int count = 0; while(true) { try { return getReadableDatabase(); } catch (SQLiteCantOpenDatabaseException e) { if (++count >= DB_OPEN_RETRY_MAX) throw e; SystemClock.sleep(count * DB_OPEN_RETRY_BACKOFF); } } }
Source:
<code>private QueryObservable createQuery(Func1<Set<String>, Boolean> tableFilter, String sql, String... args) { if (transactions.get() != null) { throw new IllegalStateException("Cannot create observable query in transaction. " + "Use query() for a query inside a transaction."); } DatabaseQuery query = new DatabaseQuery(tableFilter, sql, args); final Observable<Query> queryObservable = triggers .filter(tableFilter) .map(query) .onBackpressureLatest() .startWith(query) <START> .compose(queryTransformer) END> .observeOn(scheduler) .onBackpressureLatest() .doOnSubscribe(ensureNotInTransaction); return new QueryObservable(new Observable.OnSubscribe<Query>() { @Override public void call(Subscriber<? super Query> subscriber) { queryObservable.unsafeSubscribe(subscriber); } }); }</code><technical_language>choose scheduler instead of it</technical_language>

Target:
private QueryObservable createQuery(Func1<Set<String>, Boolean> tableFilter, String sql, String... args) { if (transactions.get() != null) { throw new IllegalStateException("Cannot create observable query in transaction. " + "Use query() for a query inside a transaction."); } DatabaseQuery query = new DatabaseQuery(tableFilter, sql, args); final Observable<Query> queryObservable = triggers .filter(tableFilter) .map(query) .onBackpressureLatest() .startWith(query) .observeOn(scheduler) .compose(queryTransformer) .onBackpressureLatest() .doOnSubscribe(ensureNotInTransaction); return new QueryObservable(new Observable.OnSubscribe<Query>() { @Override public void call(Subscriber<? super Query> subscriber) { queryObservable.unsafeSubscribe(subscriber); } }); }
Source:
<code>public boolean is(Kind... kinds) { <START> return Arrays.asList(kinds).contains(getKind()); <END> }</code><technical_language>this heavily called, a simple loop ? Kind treeKind = kind(); for (Kind kindIter : kinds) { if (treeKind == kindIter) { return true; } } return false;</technical_language>

Target:
public boolean is(Kind... kinds) { Kind treeKind = getKind(); for (Kind kindIter : kinds) { if (treeKind == kindIter) { return true; } } return false; }
Source:
<code>private static ChefService initChefService(final String client, final String validator) { try { Properties chefConfig = new Properties(); chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator); chefConfig .put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, credentialForClient(validator)); ContextBuilder builder = ContextBuilder.newBuilder(new ChefApiMetadata()) .credentials(client, credentialForClient(client)) .modules(ImmutableSet.<Module> of(new SLF4JLoggingModule())) .overrides(chefConfig); System.out.printf(">> initializing %s%n", builder.getApiMetadata()); <START> ChefContext context = (ChefContext)builder.build(); <END> return context.getChefService(); } catch (Exception e) { System.err.println("error reading private key " + e.getMessage()); System.exit(1); return null; } }</code><technical_language>[minor] Add a space? (ChefContext) builder.build(); this fixed upstream...the cast necessary here? @nacx: of changes caused this</technical_language>

Target:
private static ChefService initChefService(final String client, final String validator) { try { Properties chefConfig = new Properties(); chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator); chefConfig .put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, credentialForClient(validator)); ContextBuilder builder = ContextBuilder.newBuilder(new ChefApiMetadata()) .credentials(client, credentialForClient(client)) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule())) .overrides(chefConfig); System.out.printf(">> initializing %s%n", builder.getApiMetadata()); ChefContext context = builder.buildView(ChefContext.class); return context.getChefService(); } catch (Exception e) { System.err.println("error reading private key " + e.getMessage()); System.exit(1); return null; } }
Source:
<code>public static LintResult fromJsonObject(JSONObject json) { String name = (String) json.get("name"); String code = (String) json.get("code"); String severity = (String) json.get("severity"); String path = (String) json.get("path"); <START> Integer line = (Integer) json.opt("line"); <END> Integer charPosition = (Integer) json.opt("char"); String description = (String) json.get("description"); return new LintResult(name, code, severity, path, line, charPosition, description); }</code><technical_language>This NPE typecast null Integer</technical_language>

Target:
public static LintResult fromJsonObject(JSONObject json) { String name = (String) json.get("name"); String code = (String) json.get("code"); String severity = (String) json.get("severity"); String path = (String) json.get("path"); Integer line = (Integer) json.opt("line"); Integer charPosition = (Integer) json.opt("char"); String description = (String) json.opt("description"); return new LintResult(name, code, severity, path, line, charPosition, description); }
Source:
<code>public void testTimeout() throws Exception { final MockRenderedReportBuilder builder = Mockito.mock(MockRenderedReportBuilder.class); final Config config = CHROME_RENDERER_CONFIG; _wireMock.givenThat( get(urlEqualTo("/")) .willReturn(aResponse() .withBody("here are some bytes") .withFixedDelay(1000) ) ); final HtmlReportFormat format = new HtmlReportFormat.Builder().build(); final HtmlScreenshotRenderer renderer = new HtmlScreenshotRenderer(config, new ScheduledThreadPoolExecutor(1)); final WebPageReportSource source = TestBeanFactory.createWebPageReportSourceBuilder() .setUri(URI.create("http://localhost:" + _wireMock.port())) .build(); final CompletionStage<MockRenderedReportBuilder> stage = renderer.render( source, format, new TimeRange(Instant.EPOCH, Instant.EPOCH), builder, Duration.ofMillis(500) ); boolean cancelled = false; try { <START> stage.toCompletableFuture().get(1, TimeUnit.SECONDS); <END> } catch (final CancellationException exception) { cancelled = true; } Assert.assertTrue("render().get() should have thrown a CancellationException", cancelled); }</code><technical_language>I prefer this a completely blocking .get() put timeout test @Test(timeout=1000)</technical_language>

Target:
public void testTimeout() throws Exception { final MockRenderedReportBuilder builder = Mockito.mock(MockRenderedReportBuilder.class); final Config config = CHROME_RENDERER_CONFIG; _wireMock.givenThat( get(urlEqualTo("/")) .willReturn(aResponse() .withBody("here are some bytes") .withFixedDelay(1000) ) ); final HtmlReportFormat format = new HtmlReportFormat.Builder().build(); final HtmlScreenshotRenderer renderer = new HtmlScreenshotRenderer(config, new ScheduledThreadPoolExecutor(1)); final WebPageReportSource source = TestBeanFactory.createWebPageReportSourceBuilder() .setUri(URI.create("http://localhost:" + _wireMock.port())) .build(); final CompletionStage<MockRenderedReportBuilder> stage = renderer.render( source, format, new TimeRange(Instant.EPOCH, Instant.EPOCH), builder, Duration.ofMillis(500) ); boolean cancelled = false; try { stage.toCompletableFuture().get(); } catch (final CancellationException exception) { cancelled = true; } Assert.assertTrue("render().get() should have thrown a CancellationException", cancelled); }
Source:
<code>private void checkDoNotMockAnnotation(Class<?> typeToMock, MockCreationSettings<?> creationSettings) { ArrayList<Class<?>> unmockableTypes = new ArrayList<>( creationSettings.getExtraInterfaces()); Class<?> mockTypeToCheck = typeToMock; while (mockTypeToCheck != null && mockTypeToCheck != Object.class) { unmockableTypes.add(mockTypeToCheck); Class<?>[] interfaces = mockTypeToCheck.getInterfaces(); if (interfaces != null) { unmockableTypes.addAll(Arrays.asList(interfaces)); } mockTypeToCheck = mockTypeToCheck.getSuperclass(); } <START> if (unmockableTypes.stream().anyMatch(clazz -> clazz.isAnnotationPresent(DoNotMock.class))) { <END> throw new DoNotMockException(creationSettings.getTypeToMock() + " is annotated with @DoNoMock and can't be mocked."); } }</code><technical_language>Do want honor this specific annotation (Mockito API) _any_ annotation name "DoNotMock". more useful. For example: a library owner mark types "DoNotMock" annotation adding compile dependency mockito-core</technical_language>

Target:
private void checkDoNotMockAnnotation(Class<?> typeToMock, MockCreationSettings<?> creationSettings) { checkDoNotMockAnnotationForType(typeToMock); for (Class<?> aClass : creationSettings.getExtraInterfaces()) { checkDoNotMockAnnotationForType(aClass); } }
Source:
<code>public void htlExpression(Expression expression, Node node) { <START> if (node instanceof TagNode && ((TagNode) node).getAttributes().iterator().next().getName().equals("data-sly-list")) { <END> createViolation(node.getStartLinePosition(), RULE_MESSAGE); } }</code><technical_language>data-sly-list attribute in tag node</technical_language>

Target:
public void htlExpression(Expression expression, Node node) { if (node instanceof TagNode && (isSlyList((TagNode)node) || isSlyRepeat((TagNode)node))) { createViolation(node.getStartLinePosition(), RULE_MESSAGE); } }
Source:
<code><START> public static StringBuilder read(String fileName) throws IOException { <END> try (FileReader reader = new FileReader(fileName)) { StringBuilder result = read(reader); return result; } }</code><technical_language>This break compilation for bundles this API. this deprecated add a builder one</technical_language>

Target:
public static StringBuffer read(String fileName) throws IOException { try (FileReader reader = new FileReader(fileName)) { StringBuffer result = read(reader); return result; } }
Source:
<code>public String buildImage(final BuildImageParams params, final ProgressMonitor progressMonitor) throws IOException, InterruptedException { if (params.getRemote() != null) { DockerConnection dockerConnection = connectionFactory.openConnection(dockerDaemonUri) .query("remote", params.getRemote()); return buildImage(dockerConnection, params, progressMonitor); <START> } else { <END> final File tar = Files.createTempFile(null, ".tar").toFile(); try { File[] files = new File[params.getFiles().size()]; files = params.getFiles().toArray(files); createTarArchive(tar, files); try (InputStream tarInput = new FileInputStream(tar)) { DockerConnection dockerConnection = connectionFactory.openConnection(dockerDaemonUri) .header("Content-Type", "application/x-compressed-tar") .header("Content-Length", tar.length()) .entity(tarInput); return buildImage(dockerConnection, params, progressMonitor); } } finally { FileCleaner.addFile(tar); } } }</code><technical_language>Imho is avoid else block in cases</technical_language>

Target:
public String buildImage(final BuildImageParams params, final ProgressMonitor progressMonitor) throws IOException, InterruptedException { if (params.getRemote() != null) { DockerConnection dockerConnection = connectionFactory.openConnection(dockerDaemonUri) .query("remote", params.getRemote()); return buildImage(dockerConnection, params, progressMonitor); } final File tar = Files.createTempFile(null, ".tar").toFile(); try { File[] files = new File[params.getFiles().size()]; files = params.getFiles().toArray(files); createTarArchive(tar, files); try (InputStream tarInput = new FileInputStream(tar)) { DockerConnection dockerConnection = connectionFactory.openConnection(dockerDaemonUri) .header("Content-Type", "application/x-compressed-tar") .header("Content-Length", tar.length()) .entity(tarInput); return buildImage(dockerConnection, params, progressMonitor); } } finally { FileCleaner.addFile(tar); } }
Source:
<code>public boolean getAllowUntrustedCertificate() { <START> return vsConnectionConfig != null && vsConnectionConfig.getAllowUntrustedCertificate(); <END> }</code><technical_language>This change unnecessary. this PR limited _just_ necessary achieve this PR's aims</technical_language>

Target:
public boolean getAllowUntrustedCertificate() { return vsConnectionConfig != null ? vsConnectionConfig.getAllowUntrustedCertificate() : false; }
Source:
<code>private Class<?> classFromInternalName(String name) { try { <START> return Class.forName(name.replace('/', '.'), true, classLoader); <END> } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } }</code><technical_language>2nd parameter false force static initialization</technical_language>

Target:
private Class<?> classFromInternalName(String name) { try { return Class.forName(name.replace('/', '.'), false, classLoader); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } }
Source:
<code>synchronized void publish() { if (publishedFullRegistry == null) { throw new RuntimeException("Cannot write directly to main registry"); <START> } <END> CapabilityRegistry published = publishedFullRegistry; published.capabilities.clear(); published.capabilities.putAll(capabilities); published.possibleCapabilities.clear(); published.possibleCapabilities.putAll(possibleCapabilities); published.requirements.clear(); published.requirements.putAll(requirements); published.runtimeOnlyRequirements.clear(); published.runtimeOnlyRequirements.putAll(runtimeOnlyRequirements); }</code><technical_language>Nit: this assert</technical_language>

Target:
void publish() { assert publishedFullRegistry != null : "Cannot write directly to main registry"; writeLock.lock(); try { if (!modified) { return; } publishedFullRegistry.writeLock.lock(); try { CapabilityRegistry published = publishedFullRegistry; published.capabilities.clear(); published.capabilities.putAll(capabilities); published.possibleCapabilities.clear(); published.possibleCapabilities.putAll(possibleCapabilities); published.requirements.clear(); published.requirements.putAll(requirements); published.runtimeOnlyRequirements.clear(); published.runtimeOnlyRequirements.putAll(runtimeOnlyRequirements); modified = false; } finally { publishedFullRegistry.writeLock.unlock(); } } finally { writeLock.unlock(); } }
Source:
<code>public void close() throws ZkInterruptedException { if (LOG.isTraceEnabled()) { StackTraceElement[] calls = Thread.currentThread().getStackTrace(); LOG.trace("zkclient closing a zkclient. callStack: ", this._uid, Arrays.asList(calls)); } getEventLock().lock(); IZkConnection connection = getConnection(); try { if (connection == null || _closed) { return; } setShutdownTrigger(true); if (_asyncCallRetryThread != null) { _asyncCallRetryThread.interrupt(); _asyncCallRetryThread.join(2000); } _eventThread.interrupt(); _eventThread.join(2000); if (isManagingZkConnection()) { <START> LOG.info("zkclient{}, Closing zkclient zk: ", this._uid, ((ZkConnection) connection).getZookeeper()); <END> connection.close(); } _closed = true; setCurrentState(null); getEventLock().getStateChangedCondition().signalAll(); } catch (InterruptedException e) { if (connection != null) { try { Thread.interrupted(); if (isManagingZkConnection()) { connection.close(); } Thread.currentThread().interrupt(); } catch (InterruptedException e1) { throw new ZkInterruptedException(e1); } } } finally { getEventLock().unlock(); if (_monitor != null) { _monitor.unregister(); } LOG.info("Zkclient Closed zkclient", this._uid); } }</code><technical_language>great similar messages easier read, Closing zkclient. uid={}, zk={}</technical_language>

Target:
public void close() throws ZkInterruptedException { if (LOG.isTraceEnabled()) { StackTraceElement[] calls = Thread.currentThread().getStackTrace(); LOG.trace("Closing a zkclient uid:{}, callStack: ", _uid, Arrays.asList(calls)); } getEventLock().lock(); IZkConnection connection = getConnection(); try { if (connection == null || _closed) { return; } setShutdownTrigger(true); if (_asyncCallRetryThread != null) { _asyncCallRetryThread.interrupt(); _asyncCallRetryThread.join(2000); } _eventThread.interrupt(); _eventThread.join(2000); if (isManagingZkConnection()) { LOG.info("Closing zkclient uid:{}, zk:{}", _uid, ((ZkConnection) connection).getZookeeper()); connection.close(); } _closed = true; setCurrentState(null); getEventLock().getStateChangedCondition().signalAll(); } catch (InterruptedException e) { if (connection != null) { try { Thread.interrupted(); if (isManagingZkConnection()) { connection.close(); } Thread.currentThread().interrupt(); } catch (InterruptedException e1) { throw new ZkInterruptedException(e1); } } } finally { getEventLock().unlock(); if (_monitor != null) { _monitor.unregister(); } LOG.info("Closed zkclient with uid:{}", _uid); } }
Source:
<code>private ColumnType getColumnTypeFromRow(final Row currentRow, int index) { if (currentRow.getCell(index) == null) { return ColumnType.STRING; } else { <START> CellType cellType = currentRow.getCell(index).getCellType(); <END> switch (cellType) { case NUMERIC: if (DateUtil.isCellDateFormatted(currentRow.getCell(index))) { return ColumnType.DATE; } else { return (currentRow.getCell(index).getNumericCellValue() % 1 == 0) ? ColumnType.INTEGER : ColumnType.DOUBLE; } case BOOLEAN: return ColumnType.BOOLEAN; case ERROR: case _NONE: case STRING: case FORMULA: case BLANK: default: return ColumnType.STRING; } } }</code><technical_language>this variable final</technical_language>

Target:
protected ColumnType getColumnTypeFromRow(final Row currentRow, int index) { if (currentRow.getCell(index) == null) { return ColumnType.STRING; } else { switch (currentRow.getCell(index).getCellType()) { case NUMERIC: if (DateUtil.isCellDateFormatted(currentRow.getCell(index))) { return ColumnType.DATE; } else { return (currentRow.getCell(index).getNumericCellValue() % 1 == 0) ? ColumnType.INTEGER : ColumnType.DOUBLE; } case BOOLEAN: return ColumnType.BOOLEAN; case ERROR: case _NONE: case STRING: case FORMULA: case BLANK: default: return ColumnType.STRING; } } }
Source:
<code>public void readData(ObjectDataInput in) throws IOException { version = in.readLong(); hits = in.readLong(); ttl = in.readLong(); creationTime = in.readLong(); lastAccessTime = in.readLong(); lastUpdateTime = in.readLong(); <START> maxIdle = in.readLong(); <END> boolean statsEnabled = in.readBoolean(); lastStoredTime = statsEnabled ? in.readLong() : NOT_AVAILABLE; expirationTime = statsEnabled ? in.readLong() : NOT_AVAILABLE; }</code><technical_language>RU compatibility</technical_language>

Target:
public void readData(ObjectDataInput in) throws IOException { version = in.readLong(); hits = in.readLong(); ttl = in.readLong(); creationTime = in.readLong(); lastAccessTime = in.readLong(); lastUpdateTime = in.readLong(); boolean statsEnabled = in.readBoolean(); lastStoredTime = statsEnabled ? in.readLong() : NOT_AVAILABLE; expirationTime = statsEnabled ? in.readLong() : NOT_AVAILABLE; if (in.getVersion().isGreaterOrEqual(V3_11)) { maxIdle = in.readLong(); } }
Source:
<code><START> private String getHeadName(Ref head) { <END> String headName; if (head.isSymbolic()) headName = head.getTarget().getName(); else headName = head.getObjectId().getName(); return headName; }</code><technical_language>this method declared static</technical_language>

Target:
private static String getHeadName(Ref head) { String headName; if (head.isSymbolic()) headName = head.getTarget().getName(); else headName = head.getObjectId().getName(); return headName; }
Source:
<code>private void maintenance() { ConfirmationModel model = new ConfirmationModel(); model.setTitle(ConstantsManager.getInstance().getConstants().maintenanceStorageDomainsTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantToPlaceFollowingStorageDomainsIntoMaintenanceModeMsg()); model.setHashName("maintenance_storage_domain"); setWindow(model); boolean isDataDomain = true; List<String> items = new <START> ArrayList<>(); <END> for (Object selected : getSelectedItems()) { items.add(((StorageDomain) selected).getName()); isDataDomain = ((StorageDomain) selected).getStorageDomainType().isDataDomain(); } model.setItems(items); if (isDataDomain) { model.getForce().setIsAvailable(true); } model.getForce().setIsChangeable(true); model.getForce().setEntity(false); model.setForceLabel(ConstantsManager.getInstance().getConstants().ignoreOVFUpdateFailure()); UICommand maintenance = UICommand.createDefaultOkUiCommand("OnMaintenance", this); model.getCommands().add(maintenance); UICommand cancel = UICommand.createCancelUiCommand("Cancel", this); model.getCommands().add(cancel); }</code><technical_language>micro optimization: initialize this size getSelectedItems()</technical_language>

Target:
private void maintenance() { ConfirmationModel model = new ConfirmationModel(); model.setTitle(ConstantsManager.getInstance().getConstants().maintenanceStorageDomainsTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantToPlaceFollowingStorageDomainsIntoMaintenanceModeMsg()); model.setHashName("maintenance_storage_domain"); setWindow(model); boolean isDataDomain = false; List<String> items = new ArrayList<>(getSelectedItems().size()); for (StorageDomain selected : getSelectedItems()) { items.add(selected.getName()); isDataDomain |= selected.getStorageDomainType().isDataDomain(); } model.setItems(items); model.getForce().setIsAvailable(isDataDomain); model.getForce().setIsChangeable(isDataDomain); model.getForce().setEntity(false); model.setForceLabel(ConstantsManager.getInstance().getConstants().ignoreOVFUpdateFailure()); UICommand maintenance = UICommand.createDefaultOkUiCommand("OnMaintenance", this); model.getCommands().add(maintenance); UICommand cancel = UICommand.createCancelUiCommand("Cancel", this); model.getCommands().add(cancel); }
Source:
<code>public boolean leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(connection.getUser(), MUCLightAffiliation.none); MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); StanzaFilter responseFilter = new AndFilter(FromMatchesFilter.createBare(room.asDomainBareJid()), new StanzaTypeFilter(IQ.class)); <START> IQ responseIq = connection.createPacketCollectorAndSend(responseFilter, changeAffiliationsIQ) <END> .nextResultOrThrow(); boolean roomLeft = responseIq.getType().equals(IQ.Type.result); if (roomLeft) { removeConnectionCallbacks(); } return roomLeft; }</code><technical_language>Some issues above. Simply IQ request/response idiom reduce LOC for greater good</technical_language>

Target:
public void leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(connection.getUser(), MUCLightAffiliation.none); MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); IQ responseIq = connection.createPacketCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); boolean roomLeft = responseIq.getType().equals(IQ.Type.result); if (roomLeft) { removeConnectionCallbacks(); } }
Source:
<code>TypeDeclarationNode indexSignatureType( TypeDeclarationNode keyType, TypeDeclarationNode valueType) { TypeDeclarationNode node = new TypeDeclarationNode(Token.INDEX_SIGNATURE); TypeDeclarationNode first = null; switch (keyType.getToken()) { case STRING_TYPE: <START> first = new TypeDeclarationNode(Token.STRING_KEY, "s"); <END> break; case NUMBER_TYPE: first = new TypeDeclarationNode(Token.STRING_KEY, "n"); break; default: break; } if (null != first) { first.setDeclaredTypeExpression(keyType); node.addChildToBack(first); } node.setDeclaredTypeExpression(valueType); return node; }</code><technical_language>'key' instead of 's'</technical_language>

Target:
TypeDeclarationNode indexSignatureType( TypeDeclarationNode keyType, TypeDeclarationNode valueType) { TypeDeclarationNode node = new TypeDeclarationNode(Token.INDEX_SIGNATURE); TypeDeclarationNode first = null; first = new TypeDeclarationNode(Token.STRING_KEY, "key"); first.setDeclaredTypeExpression(keyType); node.addChildToBack(first); node.setDeclaredTypeExpression(valueType); return node; }
Source:
<code>public static void beforeClass() throws UnknownHostException, MalformedURLException { <START> AppiumServiceBuilder appiumServiceBuilder = new AppiumServiceBuilder() <END> .usingPort(4723); service = appiumServiceBuilder.build(); service.start(); InetAddress ipadd =InetAddress.getLocalHost(); String n=ipadd.toString(); String ip = n.substring(n.indexOf("/")+1); System.out.println("-------------------------------------------"); System.out.println("IP address :"+n.substring(n.indexOf("/")+1)); System.out.println(service.isRunning()); System.out.println("-------------------------------------------"); if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } File appDir = new File("src/test/java/io/appium/java_client"); File app = new File(appDir, "TestApp.app.zip"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); driver = new IOSDriver<>(new URL("http://" + ip + ":4723/wd/hub"), capabilities); }</code><technical_language>duplicated code</technical_language>

Target:
public static void beforeClass() throws UnknownHostException, MalformedURLException { String ipAddress = startAppiumServer(); if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } File appDir = new File("src/test/java/io/appium/java_client"); File app = new File(appDir, "TestApp.app.zip"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST); capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); }
Source:
<code>protected DimensionSchema(String name) { Preconditions.checkArgument(name != null, "Dimension name cannot be null."); <START> this.name = name; <END> }</code><technical_language>this.name = Preconditions.checkNotNull(name, "msg")</technical_language>

Target:
protected DimensionSchema(String name) { this.name = Preconditions.checkNotNull(name, "Dimension name cannot be null."); }
Source:
<code>public void setUp() throws Exception { BasicConfigurator.configure(); executorList.clear(); <START> executorList.add(new MockExecutorObject("Executor1",8080,50.0,2048,5,new Date(), 20, 6400)); <END> executorList.add(new MockExecutorObject("Executor2",8080,50.0,2048,4,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor3",8080,40.0,2048,1,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor4",8080,50.0,2048,4,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor5",8080,50.0,1024,5,new Date(), 90, 6400)); executorList.add(new MockExecutorObject("Executor6",8080,50.0,1024,5,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor7",8080,50.0,1024,5,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor8",8080,50.0,2048,1,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor9",8080,50.0,2050,5,new Date(), 90, 4200)); executorList.add(new MockExecutorObject("Executor10",8080,00.0,1024,1,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor11",8080,20.0,2096,3,new Date(), 90, 2400)); executorList.add(new MockExecutorObject("Executor12",8080,90.0,2050,5,new Date(), 60, 2500)); Collections.shuffle(this.executorList); }</code><technical_language>thinking Do need (12) executors unit test dispatching features? Wondering if prove aspects of dispatch executors</technical_language>

Target:
public void setUp() throws Exception { executorList.clear(); executorList.add(new MockExecutorObject("Executor1",8080,50.0,2048,5,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor2",8080,50.0,2048,4,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor3",8080,40.0,2048,1,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor4",8080,50.0,2048,4,new Date(), 20, 6400)); executorList.add(new MockExecutorObject("Executor5",8080,50.0,1024,5,new Date(), 90, 6400)); executorList.add(new MockExecutorObject("Executor6",8080,50.0,1024,5,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor7",8080,50.0,1024,5,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor8",8080,50.0,2048,1,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor9",8080,50.0,2050,5,new Date(), 90, 4200)); executorList.add(new MockExecutorObject("Executor10",8080,00.0,1024,1,new Date(), 90, 3200)); executorList.add(new MockExecutorObject("Executor11",8080,20.0,2096,3,new Date(), 90, 2400)); executorList.add(new MockExecutorObject("Executor12",8080,90.0,2050,5,new Date(), 60, 2500)); Collections.shuffle(this.executorList); }
Source:
<code>public AnalysisPropertyDto setKey(String key) { <START> checkArgument(key != null, "key cannot be null"); <END> this.key = key; return this; }</code><technical_language>simply Objects.requireNonNull</technical_language>

Target:
public AnalysisPropertyDto setKey(String key) { requireNonNull(key, "key cannot be null"); this.key = key; return this; }
Source:
<code>private CompletableFuture<Connection> connect() { if (selector.state() == AddressSelector.State.RESET && connection != null) { if (connectFuture != null) { return connectFuture; } connectFuture = new OrderedCompletableFuture<>(); <START> connectFuture.whenComplete((r, e) -> connectFuture = null); <END> Connection oldConnection = this.connection; this.connection = null; oldConnection.close(); connect(connectFuture); return connectFuture; } if (connection != null) { return CompletableFuture.completedFuture(connection); } if (connectFuture != null) { return connectFuture; } connectFuture = new OrderedCompletableFuture<>(); connectFuture.whenComplete((r, e) -> connectFuture = null); reset().connect(connectFuture); return connectFuture; }</code><technical_language>This line sets connectFuture null</technical_language>

Target:
private CompletableFuture<Connection> connect() { if (selector.state() == AddressSelector.State.RESET && connection != null) { if (connectFuture != null) { return connectFuture; } CompletableFuture<Connection> future = new OrderedCompletableFuture<>(); future.whenComplete((r, e) -> this.connectFuture = null); this.connectFuture = future; Connection oldConnection = this.connection; this.connection = null; oldConnection.close(); connect(future); return future; } if (connection != null) { return CompletableFuture.completedFuture(connection); } if (connectFuture != null) { return connectFuture; } CompletableFuture<Connection> future = new OrderedCompletableFuture<>(); future.whenComplete((r, e) -> this.connectFuture = null); this.connectFuture = future; reset().connect(future); return future; }
Source:
<code>public AffinityGroupStatusColumn() { super(new AbstractCell<AffinityGroup>() { @Override public void render(Context context, AffinityGroup group, SafeHtmlBuilder sb, String id) { if (group == null) { return; } if (Boolean.TRUE.equals(group.getBroken())) { sb.append(cellTemplate.statusWithIconTemplate( SafeHtmlUtils.fromSafeConstant(constants.affinityGroupStatusBroken()), AbstractImagePrototype.create(resources.alertImage()).getSafeHtml(), id, <START> "broken" END> )); } else { sb.append(cellTemplate.statusTemplate( SafeHtmlUtils.fromSafeConstant(constants.affinityGroupStatusOk()), id, "ok" )); } } }); }</code><technical_language>constant</technical_language>

Target:
public AffinityGroupStatusColumn() { super(new AbstractCell<AffinityGroup>() { @Override public void render(Context context, AffinityGroup group, SafeHtmlBuilder sb, String id) { if (group == null) { return; } if (Boolean.TRUE.equals(group.getBroken())) { sb.append(cellTemplate.statusWithIconTemplate( SafeHtmlUtils.fromSafeConstant(constants.affinityGroupStatusBroken()), AbstractImagePrototype.create(resources.alertImage()).getSafeHtml(), id, STATUS_BROKEN )); } else { sb.append(cellTemplate.statusTemplate( SafeHtmlUtils.fromSafeConstant(constants.affinityGroupStatusOk()), id, STATUS_OK )); } } }); }
Source:
<code>private static String[] getProGuardUuids(Context ctx) { try { <START> AssetManager assets = ctx.getAssets(); <END> InputStream is = assets.open("sentry-debug-meta.properties"); Properties properties = new Properties(); properties.load(is); is.close(); String uuid = properties.getProperty("io.sentry.ProguardUuids"); if (Util.isNullOrEmpty(uuid)) { return null; } Log.e(TAG, "UUID: " + uuid); return uuid.split("\\|"); } catch (Exception e) { Log.e(TAG, "Error getting Proguard UUIDs.", e); } return null; }</code><technical_language>Agreed, do these: <LINK_0></technical_language>

Target:
private static String[] getProGuardUuids(Context ctx) { if (cachedProGuardUuids != null) { return cachedProGuardUuids; } String[] retVal = new String[0]; try { AssetManager assets = ctx.getAssets(); InputStream is = assets.open("sentry-debug-meta.properties"); Properties properties = new Properties(); properties.load(is); is.close(); String uuid = properties.getProperty("io.sentry.ProguardUuids"); if (!Util.isNullOrEmpty(uuid)) { retVal = uuid.split("\\|"); } } catch (Exception e) { Log.e(TAG, "Error getting Proguard UUIDs.", e); } cachedProGuardUuids = retVal; return retVal; }
Source:
<code>public boolean isIndelOrSkippedRegion() { <START> return (mask & INDEL_OR_SKIP_MASK) != 0; <END> }</code><technical_language>Do show in a profiler? This a bit faster if compiler write clever if statements. curious if this is a real performance problem though</technical_language>

Target:
public boolean isIndelOrSkippedRegion() { return isIndelOrSkip; }
Source:
<code>public GuiTab(String name, ResourceLocation icon, Class<? extends GuiContainer> clazz) { this.name = name; this.iconResLoc = icon; <START> if (GuiTab.tabRegistry.get(clazz).contains(VANILLA_INVENTORY_TAB) == false) <END> { GuiTab.VANILLA_INVENTORY_TAB.addTo(clazz); } }</code><technical_language>java if (!GuiTab.tabRegistry.get(clazz).contains(VANILLA_INVENTORY_TAB))</technical_language>

Target:
public GuiTab(String name, ResourceLocation icon, Class<? extends GuiContainer> clazz) { this.name = name; this.iconResLoc = icon; if (!GuiTab.tabRegistry.get(clazz).contains(VANILLA_INVENTORY_TAB)) { } }
Source:
<code>public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { <START> return !(descriptor instanceof vSphereCloudProvisionedSlave.DescriptorImpl); <END> }</code><technical_language>former. class C { class { ... } code in class C references class C.Inner do C.Inner. ...but convinced that, expressed that, code is needed, fact this slipped suggests testing did, pick this up</technical_language>

Target:
public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !(descriptor instanceof DescriptorImpl); }
Source:
<code><START> protected void fillEdges(SPTEntry currEdge, PriorityQueue<SPTEntry> prioQueue, <END> IntObjectMap<SPTEntry> bestWeightMap, EdgeExplorer explorer, boolean reverse) { EdgeIterator iter = explorer.setBaseNode(currEdge.adjNode); while (iter.next()) { if (!accept(iter, currEdge.edge)) continue; int traversalId = traversalMode.createTraversalId(iter, reverse); double tmpWeight = weighting.calcWeight(iter, reverse, currEdge.edge) + currEdge.weight; if (Double.isInfinite(tmpWeight)) continue; SPTEntry ee = bestWeightMap.get(traversalId); if (ee == null) { ee = new SPTEntry(iter.getEdge(), iter.getAdjNode(), tmpWeight); ee.parent = currEdge; bestWeightMap.put(traversalId, ee); prioQueue.add(ee); } else if (ee.weight > tmpWeight) { prioQueue.remove(ee); ee.edge = iter.getEdge(); ee.weight = tmpWeight; ee.parent = currEdge; prioQueue.add(ee); } else continue; if (updateBestPath) updateBestPath(iter, ee, traversalId); } }</code><technical_language>This necessary IMO</technical_language>

Target:
void fillEdges(SPTEntry currEdge, PriorityQueue<SPTEntry> prioQueue, IntObjectMap<SPTEntry> bestWeightMap, EdgeExplorer explorer, boolean reverse) { EdgeIterator iter = explorer.setBaseNode(currEdge.adjNode); while (iter.next()) { if (!accept(iter, currEdge.edge)) continue; int traversalId = traversalMode.createTraversalId(iter, reverse); double tmpWeight = weighting.calcWeight(iter, reverse, currEdge.edge) + currEdge.weight; if (Double.isInfinite(tmpWeight)) continue; SPTEntry ee = bestWeightMap.get(traversalId); if (ee == null) { ee = new SPTEntry(iter.getEdge(), iter.getAdjNode(), tmpWeight); ee.parent = currEdge; bestWeightMap.put(traversalId, ee); prioQueue.add(ee); } else if (ee.weight > tmpWeight) { prioQueue.remove(ee); ee.edge = iter.getEdge(); ee.weight = tmpWeight; ee.parent = currEdge; prioQueue.add(ee); } else continue; if (updateBestPath) updateBestPath(iter, ee, traversalId); } }
Source:
<code><START> public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { <END> try { final Tika tika = new Tika(); String mimeType = tika.detect(newFile.getInputStream()); LOG.debug("File mime-type is: " + mimeType); for (String fileType : fileTypes) { if (StringUtils.equalsIgnoreCase(mimeType, fileType)) { return true; } else if (fileType.indexOf("*") == fileType.length() - 1) { fileType = fileType.substring(0, fileType.length() - 1); if (mimeType.indexOf(fileType) == 0) { return true; } } } return false; } catch (IOException e) { LOG.error("Invalid file type"); return false; } }</code><technical_language>Handle null arguments... If newFile is null, return false IllegalArgument if fileTypes is null</technical_language>

Target:
public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { if (newFile == null) { return false; } if (fileTypes == null || fileTypes.isEmpty()) { return true; } try { final Tika tika = new Tika(); String mimeType = tika.detect(newFile.getInputStream()); LOG.debug("File mime-type is: " + mimeType); for (String fileType : fileTypes) { if (StringUtils.equalsIgnoreCase(mimeType, fileType)) { return true; } else if (fileType.indexOf("*") == fileType.length() - 1) { fileType = fileType.substring(0, fileType.length() - 1); if (mimeType.indexOf(fileType) == 0) { return true; } } } return false; } catch (IOException e) { LOG.error("Invalid file type"); return false; } }
Source:
<code>public RepeatableReadEntry(Object key, Object value, Metadata metadata) { super(key, value, metadata); <START> this.oldMetadata = metadata; <END> }</code><technical_language>I need move oldMetadata ReadCommittedEntry</technical_language>

Target:
public RepeatableReadEntry(Object key, Object value, Metadata metadata) { super(key, value, metadata); }
Source:
<code>public final void visitToken(DetailAST blockCommentNode) { if (JavadocUtils.isJavadocComment(blockCommentNode)) { blockCommentAst = blockCommentNode; final String treeCacheKey = blockCommentNode.getLineNo() + ":" + blockCommentNode.getColumnNo(); final ParseStatus result; if (TREE_CACHE.get().containsKey(treeCacheKey)) { result = TREE_CACHE.get().get(treeCacheKey); } else { result = parser.parseJavadocAsDetailNode(blockCommentNode); TREE_CACHE.get().put(treeCacheKey, result); <START> } <END> if (result.getParseErrorMessage() == null) { final DetailNode javadocTree = result.getTree(); if (doesCheckAcceptJavadocWithUnclosedHtmlTag() || !JavadocUtils.hasUnclosedTag(javadocTree)) { processTree(javadocTree); } } else { final ParseErrorMessage parseErrorMessage = result.getParseErrorMessage(); log(parseErrorMessage.getLineNumber(), parseErrorMessage.getMessageKey(), parseErrorMessage.getMessageArguments()); } } }</code><technical_language>Thanks, good point. @romani, do agree</technical_language>

Target:
public final void visitToken(DetailAST blockCommentNode) { if (JavadocUtils.isJavadocComment(blockCommentNode)) { context.get().blockCommentAst = blockCommentNode; final String treeCacheKey = blockCommentNode.getLineNo() + ":" + blockCommentNode.getColumnNo(); final ParseStatus result; if (TREE_CACHE.get().containsKey(treeCacheKey)) { result = TREE_CACHE.get().get(treeCacheKey); } else { result = context.get().parser .parseJavadocAsDetailNode(blockCommentNode); TREE_CACHE.get().put(treeCacheKey, result); } if (result.getParseErrorMessage() == null) { if (acceptJavadocWithNonTightHtml() || !result.isNonTight()) { processTree(result.getTree()); } if (violateExecutionOnNonTightHtml && result.isNonTight()) { log(result.getFirstNonTightHtmlTag().getLine(), JavadocDetailNodeParser.MSG_UNCLOSED_HTML_TAG, result.getFirstNonTightHtmlTag().getText()); } } else { final ParseErrorMessage parseErrorMessage = result.getParseErrorMessage(); log(parseErrorMessage.getLineNumber(), parseErrorMessage.getMessageKey(), parseErrorMessage.getMessageArguments()); } } }
Source:
<code>private void onOk() { FenceProxyModel windowModel = (FenceProxyModel) getWindow(); <START> setWindow(null); <END> ListModel<FenceProxyModel> currentModels = windowModel.getCurrentProxies(); FenceProxyModel selectedModel = windowModel.getAvailableProxies().getSelectedItem(); setEntity(selectedModel.getEntity()); Collection<FenceProxyModel> items = currentModels.getItems(); currentModels.setItems(null); currentModels.setItems(items); }</code><technical_language>This change a bit weird. clearing Window property early close dialog? some UI exception occur applying this change? share more details? elaborate, current flow this: * model calls setWindow(null) * this triggers Window property changed event * UI infra (ModelBoundPopupHandler) sees Window property is null dialog is up.. * (!) .. dialog hidden & destroyed, calling cleanup() View model Notice item. FenceProxyModel windowModel = (FenceProxyModel) getWindow(); setWindow(null); // this point, windowModel.cleanup() is called Technically speaking, close a dialog setWindow(null) *not* access dialog's model anymore, cleaned dialog View. accessing dialog's model closed? change this</technical_language>

Target:
private void onOk() { FenceProxyModel windowModel = (FenceProxyModel) getWindow(); ListModel<FenceProxyModel> currentModels = windowModel.getCurrentProxies(); FenceProxyModel selectedModel = windowModel.getAvailableProxies().getSelectedItem(); setEntity(selectedModel.getEntity()); Collection<FenceProxyModel> items = currentModels.getItems(); currentModels.setItems(null); currentModels.setItems(items); setWindow(null); }
Source:
<code>public void verifyFactoryForSamlClients() throws Exception { val props = new Pac4jDelegatedAuthenticationProperties(); val saml = new Pac4jSamlClientProperties(); saml.setKeystorePath(new File(FileUtils.getTempDirectoryPath(), "keystore.jks").getCanonicalPath()); saml.setKeystorePassword("1234567890"); saml.setPrivateKeyPassword("1234567890"); saml.setIdentityProviderMetadataPath("classpath:idp-metadata.xml"); saml.setServiceProviderMetadataPath(new File(FileUtils.getTempDirectoryPath(), "sp.xml").getCanonicalPath()); saml.setServiceProviderEntityId("test-entityid"); saml.setForceKeystoreGeneration(true); <START> saml.setMessageStoreFactory("org.pac4j.saml.store.HttpSessionStoreFactory"); <END> props.getSaml().add(saml); val casSettings = new CasConfigurationProperties(); casSettings.getAuthn().setPac4j(props); val factory = new DelegatedClientFactory(casSettings); val clients = factory.build(); assertEquals(1, clients.size()); assertTrue(SAML2Client.class.cast(clients.iterator().next()).getConfiguration().getSamlMessageStoreFactory() instanceof org.pac4j.saml.store.HttpSessionStoreFactory); }</code><technical_language>HttpSessionStoreFactory.class.getName() class get name, if moves is deleted, catch issue compile-time</technical_language>

Target:
public void verifyFactoryForSamlClients() throws Exception { val props = new Pac4jDelegatedAuthenticationProperties(); val saml = new Pac4jSamlClientProperties(); saml.setKeystorePath(new File(FileUtils.getTempDirectoryPath(), "keystore.jks").getCanonicalPath()); saml.setKeystorePassword("1234567890"); saml.setPrivateKeyPassword("1234567890"); saml.setIdentityProviderMetadataPath("classpath:idp-metadata.xml"); saml.setServiceProviderMetadataPath(new File(FileUtils.getTempDirectoryPath(), "sp.xml").getCanonicalPath()); saml.setServiceProviderEntityId("test-entityid"); saml.setForceKeystoreGeneration(true); saml.setMessageStoreFactory(org.pac4j.saml.store.HttpSessionStoreFactory.class.getName()); props.getSaml().add(saml); val casSettings = new CasConfigurationProperties(); casSettings.getAuthn().setPac4j(props); val factory = new DelegatedClientFactory(casSettings); val clients = factory.build(); assertEquals(1, clients.size()); assertTrue(SAML2Client.class.cast(clients.iterator().next()).getConfiguration(). getSamlMessageStoreFactory() instanceof org.pac4j.saml.store.HttpSessionStoreFactory); }