auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void addLabel(PropertyType type, String value) { Label description = new Label(type.description()); description.getStyleClass().add("property-header"); Label label = new Label(value); label.getStyleClass().add("property-info"); propertyPane.getChildren().add(new VBox(description, label)); }

Target:
private void addLabel(PropertyType type, String value) { Label description = new Label(type.description()); description.getStyleClass().add("property-header"); Node label = new Label(value); label.getStyleClass().add("property-info"); if (value != null && value.length() > MAX_PROPERTY_SIZE) { ScrollPane sp = new ScrollPane(label); sp.setFitToWidth(true); sp.setPrefHeight(WIDTH); label = sp; } propertyPane.getChildren().add(new VBox(description, label)); }
Source:
public MetadataResult<ComponentMetadataDescriptor<T>> getMetadata(MetadataContext context, ParameterValueResolver metadataKeyResolver, ReflectionCache reflectionCache) { try { Object keyValue; MetadataResult keyValueResult = getMetadataKeyObjectValue(metadataKeyResolver); if (!keyValueResult.isSuccess()) { return keyValueResult; } keyValue = keyValueResult.get(); if (keyValue == null && !keyIdObjectResolver.isKeyRequired()) { return failure(newFailure().withFailureCode(INVALID_METADATA_KEY).withMessage("MetadataKey resolved to null") .onComponent()); } MetadataAttributes.MetadataAttributesBuilder builder = MetadataAttributes.builder(); if (!keyIdObjectResolver.isKeyLess()) { builder.withKey(keyIdObjectResolver.reconstructKeyFromType(keyValue, reflectionCache)); } return getMetadata(context, keyValue, builder); } catch (MetadataResolvingException e) { return failure(newFailure(e).onComponent()); } }

Target:
public MetadataResult<ComponentMetadataDescriptor<T>> getMetadata(MetadataContext context, ParameterValueResolver metadataKeyResolver, ReflectionCache reflectionCache) { try { Object keyValue; MetadataResult keyValueResult = getMetadataKeyObjectValue(metadataKeyResolver); if (!keyValueResult.isSuccess()) { return keyValueResult; } keyValue = keyValueResult.get(); if (keyValue == null && keyIdObjectResolver.isKeyRequired()) { return failure(newFailure().withFailureCode(INVALID_METADATA_KEY).withMessage("MetadataKey resolved to null") .onComponent()); } MetadataAttributes.MetadataAttributesBuilder builder = MetadataAttributes.builder(); if (!keyIdObjectResolver.isKeyLess()) { builder.withKey(keyIdObjectResolver.reconstructKeyFromType(keyValue, reflectionCache)); } return getMetadata(context, keyValue, builder); } catch (MetadataResolvingException e) { return failure(newFailure(e).onComponent()); } }
Source:
public boolean isConnected() { return this == CONNECTED || this == RECONNECTED || this == READ_ONLY; }

Target:
public boolean isConnected() { return true; }
Source:
public WorkspaceImpl updateWorkspace(String id, Workspace update) throws ConflictException, ServerException, NotFoundException, ValidationException { requireNonNull(id, "Required non-null workspace id"); requireNonNull(update, "Required non-null workspace update"); checkArgument( update.getConfig() != null || update.getDevfile() != null, "Required non-null workspace configuration or devfile update"); if (update.getConfig() != null) { validator.validateConfig(update.getConfig()); } validator.validateAttributes(update.getAttributes()); WorkspaceImpl workspace = workspaceDao.get(id); if (workspace.getConfig() != null) { workspace.setConfig(new WorkspaceConfigImpl(update.getConfig())); } if (workspace.getDevfile() != null) { workspace.setDevfile(new DevfileImpl(update.getDevfile())); } workspace.setAttributes(update.getAttributes()); workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); workspace.setTemporary(update.isTemporary()); return normalizeState(workspaceDao.update(workspace), true); }

Target:
public WorkspaceImpl updateWorkspace(String id, Workspace update) throws ConflictException, ServerException, NotFoundException, ValidationException { requireNonNull(id, "Required non-null workspace id"); requireNonNull(update, "Required non-null workspace update"); checkArgument( update.getConfig() != null ^ update.getDevfile() != null, "Required non-null workspace configuration or devfile update but not both"); if (update.getConfig() != null) { validator.validateConfig(update.getConfig()); } validator.validateAttributes(update.getAttributes()); WorkspaceImpl workspace = workspaceDao.get(id); if (workspace.getConfig() != null) { workspace.setConfig(new WorkspaceConfigImpl(update.getConfig())); } if (workspace.getDevfile() != null) { workspace.setDevfile(new DevfileImpl(update.getDevfile())); } workspace.setAttributes(update.getAttributes()); workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); workspace.setTemporary(update.isTemporary()); return normalizeState(workspaceDao.update(workspace), true); }
Source:
public SparseHll(Slice serialized) { BasicSliceInput input = serialized.getInput(); checkArgument(input.readUnsignedByte() == (SPARSE_TAG | VERSION), "Wrong type/version"); indexBitLength = input.readByte(); numberOfHashes = input.readShort(); numberOfOverflows = input.readShort(); shortHashes = new short[numberOfHashes]; for (int i = 0; i < numberOfHashes; i++) { shortHashes[i] = input.readShort(); } overflows = new short[numberOfOverflows]; for (int i = 0; i < numberOfOverflows; i++) { overflows[i] = input.readShort(); } }

Target:
public SparseHll(Slice serialized) { BasicSliceInput input = serialized.getInput(); checkArgument(input.readByte() == Format.SPARSE_V1.getTag(), "invalid format tag"); indexBitLength = input.readByte(); checkArgument(indexBitLength >= 1 && indexBitLength <= 13, "indexBitLength is out of range"); numberOfHashes = input.readShort(); numberOfOverflows = input.readShort(); shortHashes = new short[numberOfHashes]; for (int i = 0; i < numberOfHashes; i++) { shortHashes[i] = input.readShort(); } overflows = new short[numberOfOverflows]; for (int i = 0; i < numberOfOverflows; i++) { overflows[i] = input.readShort(); } checkArgument(!input.isReadable(), "input is too big"); }
Source:
@Override protected UnifyResult apply(UnifyRuleCall call) { final MutableScan query = (MutableScan) call.query; final MutableCalc target = (MutableCalc) call.target; final MutableScan targetInput = (MutableScan) target.getInput(); final Pair<RexNode, List<RexNode>> targetExplained = explainCalc(target); final RexNode targetCond = targetExplained.left; final List<RexNode> targetProjs = targetExplained.right; final RexBuilder rexBuilder = call.getCluster().getRexBuilder(); if (query.equals(targetInput) && targetCond.isAlwaysTrue()) { final RexShuttle shuttle = getRexShuttle(targetProjs); final List<RexNode> compenProjs; try { compenProjs = (List<RexNode>) shuttle.apply(rexBuilder.identityProjects(query.rowType)); } catch (MatchFailed e) { return null; } if (RexUtil.isIdentity(compenProjs, target.rowType)) { return call.result(target); } else { RexProgram compenRexProgram = RexProgram.create( target.rowType, compenProjs, null, query.rowType, rexBuilder); MutableCalc compenCalc = MutableCalc.of(target, compenRexProgram); return tryMergeParentCalcAndGenResult(call, compenCalc); } } return null; }

Target:
@Override protected UnifyResult apply(UnifyRuleCall call) { final MutableScan query = (MutableScan) call.query; final MutableCalc target = (MutableCalc) call.target; final MutableScan targetInput = (MutableScan) target.getInput(); final Pair<RexNode, List<RexNode>> targetExplained = explainCalc(target); final RexNode targetCond = targetExplained.left; final List<RexNode> targetProjs = targetExplained.right; final RexBuilder rexBuilder = call.getCluster().getRexBuilder(); if (!query.equals(targetInput) || !targetCond.isAlwaysTrue()) { return null; } final RexShuttle shuttle = getRexShuttle(targetProjs); final List<RexNode> compenProjs; try { compenProjs = (List<RexNode>) shuttle.apply( rexBuilder.identityProjects(query.rowType)); } catch (MatchFailed e) { return null; } if (RexUtil.isIdentity(compenProjs, target.rowType)) { return call.result(target); } else { RexProgram compenRexProgram = RexProgram.create( target.rowType, compenProjs, null, query.rowType, rexBuilder); MutableCalc compenCalc = MutableCalc.of(target, compenRexProgram); return tryMergeParentCalcAndGenResult(call, compenCalc); } }
Source:
public void propagate_RuntimeException_when_handler_throws() { ModelTests.clearModel(); FaultyAggregate faultyAggregate = new FaultyAggregate(ID, true, false); Command command = Given.ACommand.createProject(); try { dispatchCommand(faultyAggregate, env(command.getMessage())); failNotThrows(); } catch (RuntimeException e) { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") Throwable cause = getRootCause(e); assertTrue(cause instanceof IllegalStateException); assertEquals(FaultyAggregate.BROKEN_HANDLER, cause.getMessage()); } }

Target:
public void propagate_RuntimeException_when_handler_throws() { ModelTests.clearModel(); FaultyAggregate faultyAggregate = new FaultyAggregate(ID, true, false); Command command = Given.ACommand.createProject(); try { dispatchCommand(faultyAggregate, env(command.getMessage())); failNotThrows(); } catch (RuntimeException e) { Throwable cause = getRootCause(e); assertTrue(cause instanceof IllegalStateException); assertEquals(FaultyAggregate.BROKEN_HANDLER, cause.getMessage()); } }
Source:
public AccessControlInfo(AccessControl accessControl, Identity identity) { this.accessControl = accessControl; this.identity = identity; }

Target:
public AccessControlInfo(AccessControl accessControl, Identity identity) { this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.identity = requireNonNull(identity, "identity is null"); }
Source:
public void closesExplicitlyAllParts() throws Exception { final String body = "RqMtFakeTest.closesExplicitlyAllParts"; final RqMultipart request = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), new FormattedText( "Content-Length: %s", body.getBytes().length ).asString(), "Content-Disposition: form-data; name=\"foo\"" ), new RqWithHeaders( new RqFake("", "", body), "Content-Length: 0", "Content-Disposition: form-data; name=\"bar\"; filename=\"a.bin\"" ) ); final String foo = "foo"; final String bar = "bar"; final RqMtBase multi = new RqMtBase(request); multi.body().close(); MatcherAssert.assertThat( multi.part(foo).iterator().next(), Matchers.notNullValue() ); multi.part(foo).iterator().next().body().close(); MatcherAssert.assertThat( multi.part(bar).iterator().next(), Matchers.notNullValue() ); multi.part(bar).iterator().next().body().close(); }

Target:
public void closesExplicitlyAllParts() throws Exception { final String body = "RqMtFakeTest.closesExplicitlyAllParts"; final RqMultipart request = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), new FormattedText( RqMtFakeTest.CONTENT_LENGTH, body.getBytes().length ).asString(), new FormattedText( RqMtFakeTest.CONTENT_DISP, "name=\"foo\"" ).asString() ), new RqWithHeaders( new RqFake("", "", body), new FormattedText(RqMtFakeTest.CONTENT_LENGTH, 0).asString(), new FormattedText( RqMtFakeTest.CONTENT_DISP, "name=\"bar\"; filename=\"a.bin\"" ).asString() ) ); final String foo = "foo"; final String bar = "bar"; final RqMtBase multi = new RqMtBase(request); multi.body().close(); MatcherAssert.assertThat( multi.part(foo).iterator().next(), Matchers.notNullValue() ); multi.part(foo).iterator().next().body().close(); MatcherAssert.assertThat( multi.part(bar).iterator().next(), Matchers.notNullValue() ); multi.part(bar).iterator().next().body().close(); }
Source:
public PagedSessionDataDto getAll(int start, int length) { checkArgument(start >= 0, "start is negative"); checkArgument(length >= 0, "length is negative"); long timestamp = System.currentTimeMillis(); long totalSize; List<SessionDataDto> sessionDataDtoList; totalSize = (Long) entityManager.createQuery("select count(sessionData.id) from SessionData as sessionData").getSingleResult(); try { if (commonDataService.getWebClientProperties().isUserCommentStoreAvailable() || commonDataService.getWebClientProperties().isTagsAvailable()) { sessionDataDtoList = getAllWithMetaData(start, length); } else { sessionDataDtoList = getAllNoMetaData(start, length); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } if (sessionDataDtoList.isEmpty()) { return new PagedSessionDataDto(Collections.<SessionDataDto>emptyList(), 0); } log.info("There was loaded sessions data from for ms", new Object[]{sessionDataDtoList.size(), totalSize, System.currentTimeMillis() - timestamp}); return new PagedSessionDataDto(sessionDataDtoList, (int) totalSize); }

Target:
public PagedSessionDataDto getAll(int start, int length) { checkArgument(start >= 0, "start is negative"); checkArgument(length >= 0, "length is negative"); long timestamp = System.currentTimeMillis(); long totalSize; List<SessionDataDto> sessionDataDtoList; totalSize = (Long) entityManager.createQuery("select count(sessionData.id) from SessionData as sessionData").getSingleResult(); try { sessionDataDtoList = getAllWithMetaData(start, length); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } if (sessionDataDtoList.isEmpty()) { return new PagedSessionDataDto(Collections.<SessionDataDto>emptyList(), 0); } log.info("There was loaded sessions data from for ms", new Object[]{sessionDataDtoList.size(), totalSize, System.currentTimeMillis() - timestamp}); return new PagedSessionDataDto(sessionDataDtoList, (int) totalSize); }
Source:
public void testHead() throws DDFException { HDFSDDF csvDDF = manager.newDDF("/user/jing/year.csv", null, null); List<String> rows = manager.head(csvDDF, 5); assert(rows.size() == 2); LOG.info("========== content of year.csv =========="); for (String s : rows) { System.out.println(s); } rows = manager.head(csvDDF, 20000); assert(rows.size() == 2); rows = manager.head(csvDDF, 1000); assert(rows.size() == 2); HDFSDDF folderDDF = manager.newDDF("/user/jing/testFolder", null, null); rows = manager.head(folderDDF, 5); assert (rows.size() == 4); HDFSDDF ddf1024 = manager.newDDF("/user/jing/1024.csv", null, null); rows = manager.head(ddf1024, 9999); assert (rows.size() == 1000); }

Target:
public void testHead() throws DDFException { HDFSDDF csvDDF = manager.newDDF("/test_pe/csv/small/1.csv", null, null); List<String> rows = manager.head(csvDDF, 5); assert(rows.size() == 2); rows = manager.head(csvDDF, 20000); assert(rows.size() == 2); rows = manager.head(csvDDF, 1000); assert(rows.size() == 2); HDFSDDF folderDDF = manager.newDDF("/test_pe/csv/small", null, null); rows = manager.head(folderDDF, 5); assert (rows.size() == 4); HDFSDDF ddf1024 = manager.newDDF("/test_pe/csv/fixed_len/1024.csv", null, null); rows = manager.head(ddf1024, 9999); assert (rows.size() == 1000); }
Source:
private State objectToState(Object value, String itemName) { String valueStr = String.valueOf(value); if (itemRegistry != null) { try { Item item = itemRegistry.getItem(itemName); if (item instanceof ColorItem || item instanceof DimmerItem) { return item.getState(); } else if (item instanceof SwitchItem) { return convertToSwitchOutput(valueStr).equals(DIGITAL_VALUE_OFF) ? OnOffType.OFF : OnOffType.ON; } else if (item instanceof ContactItem) { return (convertToContactOutput(valueStr).equals(DIGITAL_VALUE_CLOSED)) ? OpenClosedType.CLOSED : OpenClosedType.OPEN; } else if (item instanceof GenericItem) { return item.getState(); } } catch (ItemNotFoundException e) { logger.warn("Could not find item '{}' in registry", itemName); } } return new StringType(valueStr); }

Target:
private State objectToState(Object value, String itemName) { String valueStr = String.valueOf(value); if (itemRegistry != null) { try { Item item = itemRegistry.getItem(itemName); if (item instanceof ColorItem || item instanceof DimmerItem) { return item.getState(); } else if (item instanceof SwitchItem) { return string2DigitalValue(valueStr).equals(DIGITAL_VALUE_OFF) ? OnOffType.OFF : OnOffType.ON; } else if (item instanceof ContactItem) { return (string2DigitalValue(valueStr).equals(DIGITAL_VALUE_OFF)) ? OpenClosedType.CLOSED : OpenClosedType.OPEN; } else if (item instanceof GenericItem) { return item.getState(); } } catch (ItemNotFoundException e) { logger.warn("Could not find item '{}' in registry", itemName); } } return new StringType(valueStr); }
Source:
private static String getMavenHome() throws OwaspDiffRunnerException { String mavenHome; String mavenVersionInfo; try { mavenVersionInfo = IOUtils.toString(runTime.exec(MAVEN_VERSION_COMMAND).getInputStream()); mavenHome = Arrays.stream(mavenVersionInfo.split(System.getProperty("line.separator"))) .filter(str -> str.contains("Maven home:")) .findFirst() .orElse(null); if (mavenHome != null) { mavenHome = mavenHome.split("Maven home:")[1].trim(); } } catch (Exception e) { throw new OwaspDiffRunnerException(OwaspDiffRunnerException.UNABLE_TO_RETRIEVE_MAVEN_HOME, e); } return mavenHome; }

Target:
private static String getMavenHome() throws OwaspDiffRunnerException { String mavenVersionInfo; try { mavenVersionInfo = IOUtils.toString( runTime.exec(MAVEN_VERSION_COMMAND).getInputStream(), StandardCharsets.UTF_8.name()); return Arrays.stream(mavenVersionInfo.split(System.getProperty("line.separator"))) .filter(str -> str.contains("Maven home:")) .findFirst() .map(s -> s.split("Maven home:")[1]) .map(String::trim) .orElseThrow( () -> new OwaspDiffRunnerException( OwaspDiffRunnerException.UNABLE_TO_RETRIEVE_MAVEN_HOME)); } catch (OwaspDiffRunnerException e) { throw e; } catch (Exception e) { throw new OwaspDiffRunnerException(OwaspDiffRunnerException.UNABLE_TO_RETRIEVE_MAVEN_HOME, e); } }
Source:
public SimpleLocalMemoryContext(AggregatedMemoryContext parentMemoryContext) { this.parentMemoryContext = requireNonNull(parentMemoryContext); }

Target:
public SimpleLocalMemoryContext(AggregatedMemoryContext parentMemoryContext) { this.parentMemoryContext = requireNonNull(parentMemoryContext, "parentMemoryContext is null"); }
Source:
public PhysicalPlan<OperatorChain> chainOperators(final PhysicalPlan<Operator> plan) { final Map<SourceGenerator, Set<OperatorChain>> sourceMap = new HashMap<>(); final Map<OperatorChain, Set<Sink>> sinkMap = new HashMap<>(); final DAG<OperatorChain> operatorChainDAG = new AdjacentListDAG<>(); final Map<Operator, OperatorChain> operatorChainMap = new HashMap<>(); for (final Map.Entry<SourceGenerator, Set<Operator>> entry : plan.getSourceMap().entrySet()) { final Set<Operator> rootOperators = entry.getValue(); final Set<OperatorChain> operatorChains = new HashSet<>(); for (final Operator rootOperator : rootOperators) { final OperatorChain newOperatorChain = getNewOperatorChain(); operatorChainMap.put(rootOperator, newOperatorChain); newOperatorChain.insertToTail(rootOperator); chainOperatorHelper(plan, operatorChainMap, operatorChainDAG, sinkMap, rootOperator, null, newOperatorChain); operatorChains.add(newOperatorChain); } sourceMap.put(entry.getKey(), operatorChains); } return new DefaultPhysicalPlanImpl<>(sourceMap, operatorChainDAG, sinkMap); }

Target:
public PhysicalPlan<OperatorChain> chainOperators(final PhysicalPlan<Operator> plan) { final Map<SourceGenerator, Set<OperatorChain>> sourceMap = new HashMap<>(); final Map<OperatorChain, Set<Sink>> sinkMap = new HashMap<>(); final DAG<OperatorChain> operatorChainDAG = new AdjacentListDAG<>(); final Map<Operator, OperatorChain> operatorChainMap = new HashMap<>(); for (final Map.Entry<SourceGenerator, Set<Operator>> entry : plan.getSourceMap().entrySet()) { final Set<Operator> rootOperators = entry.getValue(); final Set<OperatorChain> operatorChains = new HashSet<>(); for (final Operator rootOperator : rootOperators) { OperatorChain currOpChain = operatorChainMap.get(rootOperator); if (currOpChain == null) { currOpChain = new DefaultOperatorChain(); operatorChainMap.put(rootOperator, currOpChain); currOpChain.insertToTail(rootOperator); chainOperatorHelper(plan, operatorChainMap, operatorChainDAG, sinkMap, rootOperator, null, currOpChain); } operatorChains.add(currOpChain); } sourceMap.put(entry.getKey(), operatorChains); } return new DefaultPhysicalPlanImpl<>(sourceMap, operatorChainDAG, sinkMap); }
Source:
private Connection getConn() throws Exception { Map<String, String> env = System.getenv(); String opts[] = {"POSTGRES_USER", "POSTGRES_PASS", "POSTGRES_JDBC_URL", "POSTGRES_DB"}; for (String opt : opts) { if (env.get(opt) == null) { throw new Exception("Environment var '" + opt + "' not set"); } } Properties props = new Properties(); props.setProperty("user", env.get("POSTGRES_USER")); props.setProperty("password", env.get("POSTGRES_PASS")); props.setProperty("database", env.get("POSTGRES_DB")); props.setProperty("driver", "org.postgresql.Driver"); String url = String.format("%s/%s",env.get("POSTGRES_JDBC_URL"), env.get("POSTGRES_DB")); return DriverManager.getConnection(url, props); }

Target:
private Connection getConn() throws Exception { Map<String, String> env = System.getenv(); String opts[] = {"POSTGRES_USER", "POSTGRES_PASS", "POSTGRES_JDBC_URL", "POSTGRES_DB"}; for (String opt : opts) { if (env.get(opt) == null) { throw new Exception("Environment var '" + opt + "' not set"); } } Properties props = new Properties(); props.setProperty("user", env.get("POSTGRES_USER")); props.setProperty("password", env.get("POSTGRES_PASS")); props.setProperty("database", env.get("POSTGRES_DB")); props.setProperty("ssl", "true"); props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); props.setProperty("driver", "org.postgresql.Driver"); String url = String.format("%s/%s", env.get("POSTGRES_JDBC_URL"), env.get("POSTGRES_DB")); return DriverManager.getConnection(url, props); }
Source:
public void testPreferences() throws Exception { ExtSed sed = new ExtSed("test"); IrisStarTableAdapter adapter = new IrisStarTableAdapter(null); SedModel model = new SedModel(sed, adapter); assertEquals(0, model.getAllSegmentModels().size()); Segment seg1 = createSampleSegment(); sed.addSegment(seg1); model.refresh(); assertEquals(1, model.getAllSegmentModels().size()); model.addSegment(seg1); assertEquals(1, model.getAllSegmentModels().size()); Segment seg2 = createSampleSegment(); sed.addSegment(seg2); model.refresh(); assertEquals(2, model.getAllSegmentModels().size()); SegmentModel layer1 = model.getSegmentModel(seg1); SegmentModel layer2 = model.getSegmentModel(seg2); assertFalse(layer1.getSuffix().equals(layer2.getSuffix())); String color2 = model.getSegmentModel(seg2).getMarkColor(); assertNotEquals( model.getSegmentModel(seg1).getMarkColor(), model.getSegmentModel(seg2).getMarkColor()); assertEquals(3, layer1.getInSource().getRowCount()); assertEquals(3, layer2.getInSource().getRowCount()); sed.remove(seg1); model.refresh(); assertEquals(1, model.getAllSegmentModels().size()); assertEquals(color2, model.getSegmentModel(seg2).getMarkColor()); assertNotNull(model.getSegmentModel(seg2)); assertNotNull(model.getSegmentModel(seg2).getInSource()); assertEquals(sed.getSegment(0).getFluxAxisUnits(), model.getYunits()); assertEquals(sed.getSegment(0).getSpectralAxisUnits(), model.getXunits()); }

Target:
public void testPreferences() throws Exception { ExtSed sed = new ExtSed("test"); sed.setManaged(false); IrisStarTableAdapter adapter = new IrisStarTableAdapter(null); SedModel model = new SedModel(sed, adapter); assertEquals(0, model.getAllSegmentModels().size()); Segment seg1 = createSampleSegment(); sed.addSegment(seg1); model.refresh(); assertEquals(1, model.getAllSegmentModels().size()); model.addSegment(seg1); assertEquals(1, model.getAllSegmentModels().size()); Segment seg2 = createSampleSegment(); sed.addSegment(seg2); model.refresh(); assertEquals(2, model.getAllSegmentModels().size()); SegmentModel layer1 = model.getSegmentModel(seg1); SegmentModel layer2 = model.getSegmentModel(seg2); assertFalse(layer1.getSuffix().equals(layer2.getSuffix())); String color2 = model.getSegmentModel(seg2).getMarkColor(); assertNotEquals( model.getSegmentModel(seg1).getMarkColor(), model.getSegmentModel(seg2).getMarkColor()); assertEquals(3, layer1.getInSource().getRowCount()); assertEquals(3, layer2.getInSource().getRowCount()); sed.remove(seg1); model.refresh(); assertEquals(1, model.getAllSegmentModels().size()); assertEquals(color2, model.getSegmentModel(seg2).getMarkColor()); assertNotNull(model.getSegmentModel(seg2)); assertNotNull(model.getSegmentModel(seg2).getInSource()); assertEquals(sed.getSegment(0).getFluxAxisUnits(), model.getYunits()); assertEquals(sed.getSegment(0).getSpectralAxisUnits(), model.getXunits()); }
Source:
public List<Class<? extends WindupRuleProvider>> getExecuteBefore() { Rules ann = this.getClass().getAnnotation(Rules.class); if(ann != null) return Arrays.asList(ann.before()); else return Collections.emptyList(); }

Target:
public List<Class<? extends WindupRuleProvider>> getExecuteBefore() { Rules rulesAnnotation = this.getClass().getAnnotation(Rules.class); if(rulesAnnotation != null) return Arrays.asList(rulesAnnotation.before()); else return Collections.emptyList(); }
Source:
public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { player.discard(player.getHand(), source, game); } return false; }

Target:
public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player == null) { return false; } player.discard(player.getHand(), source, game); return true; }
Source:
private boolean validateBricks(List<GlusterBrickEntity> newBricks) { for (GlusterBrickEntity brick : newBricks) { GlusterBrickEntity existingBrick = getGlusterBrickDao().getBrickByServerIdAndDirectory(brick.getServerId(), brick.getBrickDirectory()); if (existingBrick != null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICK_ALREADY_EXISTS_IN_VOLUME); addCanDoActionMessage(String.format("$brick %1$s", brick.getQualifiedName())); addCanDoActionMessage(String.format("$volumeName %1$s", getGlusterVolumeDao().getById(existingBrick.getVolumeId()).getName())); return false; } } return true; }

Target:
private boolean validateBricks(List<GlusterBrickEntity> newBricks) { Set<String> bricks = new HashSet<String>(); for (GlusterBrickEntity brick : newBricks) { if (bricks.contains(brick.getQualifiedName())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DUPLICATE_BRICKS); addCanDoActionMessage(String.format("$brick %1$s", brick.getQualifiedName())); return false; } bricks.add(brick.getQualifiedName()); GlusterBrickEntity existingBrick = getGlusterBrickDao().getBrickByServerIdAndDirectory(brick.getServerId(), brick.getBrickDirectory()); if (existingBrick != null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICK_ALREADY_EXISTS_IN_VOLUME); addCanDoActionMessage(String.format("$brick %1$s", brick.getQualifiedName())); addCanDoActionMessage(String.format("$volumeName %1$s", getGlusterVolumeDao().getById(existingBrick.getVolumeId()).getName())); return false; } } return true; }
Source:
public HttpRequest filter(HttpRequest request) throws HttpException { request = this.replaceDateHeader(request); request = this.replaceHostHeader(request); utils.logRequest(signatureLog, request, ">>"); request = this.signer.sign(request); utils.logRequest(signatureLog, request, "<<"); return request; }

Target:
public HttpRequest filter(HttpRequest request) throws HttpException { request = request.toBuilder().removeHeader(HttpHeaders.DATE) .replaceHeader(GlacierHeaders.ALTERNATE_DATE, timeStampProvider.get()) .replaceHeader(HttpHeaders.HOST, request.getEndpoint().getHost()).build(); utils.logRequest(signatureLog, request, ">>"); request = this.signer.sign(request); utils.logRequest(signatureLog, request, "<<"); return request; }
Source:
public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null || mCalled) { return; } mCalled = true; Bundle params = getArguments().getBundle(ExtraConstants.PARAMS); String phone = null; String countryIso = null; String nationalNumber = null; if (params != null) { phone = params.getString(ExtraConstants.PHONE); countryIso = params.getString(ExtraConstants.COUNTRY_ISO); nationalNumber = params.getString(ExtraConstants.NATIONAL_NUMBER); } if (!TextUtils.isEmpty(phone)) { start(PhoneNumberUtils.getPhoneNumber(phone)); } else if (!TextUtils.isEmpty(countryIso) && !TextUtils.isEmpty(nationalNumber)) { start(PhoneNumberUtils.getPhoneNumber(countryIso, nationalNumber)); } else if (!TextUtils.isEmpty(countryIso)) { setCountryCode(new PhoneNumber( "", countryIso, String.valueOf(PhoneNumberUtils.getCountryCode(countryIso)))); } else if (getFlowParams().enableHints) { FlowUtils.unhandled(this, new PendingIntentRequiredException( Credentials.getClient(mHandler.getApplication()).getHintPickerIntent( new HintRequest.Builder().setPhoneNumberIdentifierSupported(true) .build()), RequestCodes.CRED_HINT)); } }

Target:
public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mCheckPhoneHandler.getOperation().observe(this, new ResourceObserver<PhoneNumber>(this) { @Override protected void onSuccess(@NonNull PhoneNumber number) { start(number); } @Override protected void onFailure(@NonNull Exception e) { } }); if (savedInstanceState != null || mCalled) { return; } mCalled = true; Bundle params = getArguments().getBundle(ExtraConstants.PARAMS); String phone = null; String countryIso = null; String nationalNumber = null; if (params != null) { phone = params.getString(ExtraConstants.PHONE); countryIso = params.getString(ExtraConstants.COUNTRY_ISO); nationalNumber = params.getString(ExtraConstants.NATIONAL_NUMBER); } if (!TextUtils.isEmpty(phone)) { start(PhoneNumberUtils.getPhoneNumber(phone)); } else if (!TextUtils.isEmpty(countryIso) && !TextUtils.isEmpty(nationalNumber)) { start(PhoneNumberUtils.getPhoneNumber(countryIso, nationalNumber)); } else if (!TextUtils.isEmpty(countryIso)) { setCountryCode(new PhoneNumber( "", countryIso, String.valueOf(PhoneNumberUtils.getCountryCode(countryIso)))); } else if (getFlowParams().enableHints) { mCheckPhoneHandler.fetchCredential(); } }
Source:
public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()).image(NO_IMAGE) : null; return this; }

Target:
public DockerTemplateOptions configBuilder(Config.Builder configBuilder) { this.configBuilder = configBuilder != null ? Config.builder().fromConfig(configBuilder.image(NO_IMAGE).build()) : null; return this; }
Source:
protected List<DynamicStringProperty> getReloadSettings() { List<DynamicStringProperty> list = new ArrayList<DynamicStringProperty>(); list.add(SecurityConstants.AUTH_ENABLER_SETTING); list.add(SECURITY_SETTING); list.add(AUTH_SERVICE_LOG_LEVEL); list.add(AUTH_SERVICE_CONFIG_UPDATE_TIMESTAMP); list.add(AUTH_SERVICE_REDIRECT_WHITELIST_SETTING); return list; }

Target:
protected List<DynamicStringProperty> getReloadSettings() { List<DynamicStringProperty> list = new ArrayList<DynamicStringProperty>(); list.add(SecurityConstants.AUTH_ENABLER_SETTING); list.add(SECURITY_SETTING); list.add(AUTH_SERVICE_LOG_LEVEL); list.add(AUTH_SERVICE_CONFIG_UPDATE_TIMESTAMP); list.add(API_AUTH_SHIBBOLETH_REDIRECT_WHITELIST_SETTING); return list; }
Source:
public JavaType getSuperclass() { JavaType firstBound = bounds().get(0); if (!firstBound.getSymbol().isInterface()) { return firstBound; } return null; }

Target:
public JavaType getSuperclass() { JavaType firstBound = bounds().get(0); if (!firstBound.symbol().isInterface()) { return firstBound; } return getObjectType(firstBound); }
Source:
public Map<String, Long> getTaskManagerExternalResources() { return ExternalResourceUtils.getExternalResourceConfigMap(getFlinkConfiguration(), ExternalResourceConstants.EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX); }

Target:
public Map<String, Long> getTaskManagerExternalResources() { return taskManagerExternalResources; }
Source:
public Comparator getComparator() { return new Comparator() { @Override public int compare(Object o1, Object o2) { return Doubles.compare(((SerializablePair<Long, Double>) o1).rhs, ((SerializablePair<Long, Double>) o2).rhs); } }; }

Target:
public Comparator getComparator() { return DoubleFirstAggregatorFactory.VALUE_COMPARATOR; }
Source:
public void onEvent(InstallerLogEvent event) { InstallerLogEvent.Stream stream = event.getStream(); String text = event.getText(); if (stream != null && stream == InstallerLogEvent.Stream.STDERR && !isNullOrEmpty(text)) { RuntimeIdentityDto identity = event.getRuntimeId(); LOG.error( "Installer error from machine={} owner={} env={} workspace={} text={} time={} ", event.getInstaller(), event.getMachineName(), identity.getOwnerId(), identity.getEnvName(), identity.getWorkspaceId(), event.getText(), event.getTime()); } }

Target:
public void onEvent(InstallerLogEvent event) { if (event.getStream() == InstallerLogEvent.Stream.STDERR && !isNullOrEmpty(event.getText())) { RuntimeIdentityDto identity = event.getRuntimeId(); LOG.error( "Installer `{}` error from machine=`{}` owner=`{}` env=`{}` workspace=`{}` text=`{}` time=`{}`", event.getInstaller(), event.getMachineName(), identity.getOwnerId(), identity.getEnvName(), identity.getWorkspaceId(), event.getText(), event.getTime()); } }
Source:
public String expand(String input) { input = input.toLowerCase(); List<String> words = Arrays.asList(input.split(" ")); List<String> cleanWords = new ArrayList<>(); for (String word : words) { String cleanWord = clean(word); String britishWord = britisise(cleanWord); cleanWords.add(britishWord); } Iterable<String> transform = Iterables.transform(cleanWords, expander); return String.join(" ", transform); }

Target:
public String expand(String input) { input = input.toLowerCase(); List<String> words = Arrays.asList(input.split(" ")); String lastWord = words.get(words.size() - 1); words.set(words.size() - 1, convertRomanNumerals(lastWord)); List<String> cleanWords = words.stream() .map(this::americanize) .map(expander::apply).collect(Collectors.toList()); return String.join(" ", cleanWords); }
Source:
void selectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) throws IOException { PackList pList = packList.get(); SEARCH: for (;;) { for (PackFile p : pList.packs) { try { LocalObjectRepresentation rep = p.representation(curs, otp); p.resetTransientErrorCount(); if (rep != null) packer.select(otp, rep); } catch (PackMismatchException e) { pList = scanPacks(pList); continue SEARCH; } catch (IOException e) { handlePackError(e, p); } } break SEARCH; } }

Target:
void selectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs) { PackList pList = packList.get(); SEARCH: for (;;) { for (PackFile p : pList.packs) { try { LocalObjectRepresentation rep = p.representation(curs, otp); p.resetTransientErrorCount(); if (rep != null) packer.select(otp, rep); } catch (PackMismatchException e) { pList = scanPacks(pList); continue SEARCH; } catch (IOException e) { handlePackError(e, p); } } break SEARCH; } }
Source:
public SelenideElement getSortingButton(String selector) { ElementsCollection buttons = this.elt.$$(".projects-facet-sort a"); return buttons.find(new Condition("AttributeMatch") { @Override public boolean apply(WebElement webElement) { return webElement.getAttribute("href").matches(".*sort=" + selector + ".*"); } }); }

Target:
private SelenideElement getSortingButton(String selector) { ElementsCollection buttons = this.elt.$$(".projects-facet-sort a"); return buttons.find(new Condition("AttributeMatch") { @Override public boolean apply(WebElement webElement) { return webElement.getAttribute("href").matches(".*sort=" + selector + ".*"); } }); }
Source:
public void setFieldValue(@NonNull String name, Object value) { for (int i = 0; i < fFields.size(); i++) { if (fFields.get(i).getName().equals(name)) { fFields.get(i).fValue = value; return; } } TextTraceEventContent field = new TextTraceEventContent(name); field.setValue(value); fFields.add(field); }

Target:
public void setFieldValue(@NonNull String name, Object value) { TextTraceEventContent field = null; for (int i = 0; i < fFields.size(); i++) { if (fFields.get(i).getName().equals(name)) { field = fFields.get(i); field.setValue(value); } } if (field == null) { field = new TextTraceEventContent(name); field.setValue(value); fFields.add(field); } }
Source:
private void openPrivacyPolicyDialog(final Context context, final String action) { new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.privacy_policy_title) .setMessage(R.string.start_accept_privacy_policy) .setCancelable(false) .setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> { Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.privacy_policy_url)) ); context.startActivity(webIntent); }) .setPositiveButton(R.string.accept, (dialog, which) -> { if (action.equals("EMAIL")) { final Intent i = new Intent(Intent.ACTION_SENDTO) .setData(Uri.parse("mailto:")) .putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS}) .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) .putExtra(Intent.EXTRA_TEXT, buildJson()); if (i.resolveActivity(getPackageManager()) != null) { startActivity(i); } } else if (action.equals("GITHUB")) { ShareUtils.openUrlInBrowser(this, ERROR_GITHUB_ISSUE_URL); } }) .setNegativeButton(R.string.decline, (dialog, which) -> { }) .show(); }

Target:
private void openPrivacyPolicyDialog(final Context context, final String action) { new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.privacy_policy_title) .setMessage(R.string.start_accept_privacy_policy) .setCancelable(false) .setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> { ShareUtils.openUrlInBrowser(context, context.getString(R.string.privacy_policy_url)); }) .setPositiveButton(R.string.accept, (dialog, which) -> { if (action.equals("EMAIL")) { final Intent i = new Intent(Intent.ACTION_SENDTO) .setData(Uri.parse("mailto:")) .putExtra(Intent.EXTRA_EMAIL, new String[]{ERROR_EMAIL_ADDRESS}) .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) .putExtra(Intent.EXTRA_TEXT, buildJson()); if (i.resolveActivity(getPackageManager()) != null) { startActivity(i); } } else if (action.equals("GITHUB")) { ShareUtils.openUrlInBrowser(this, ERROR_GITHUB_ISSUE_URL); } }) .setNegativeButton(R.string.decline, (dialog, which) -> { }) .show(); }
Source:
public boolean exists(final String key) { return get(key) != null; }

Target:
public boolean exists(final String key) { return this.items.containsKey(key); }
Source:
protected void EndSuccessfully() { EndActionOnAllImageGroups(); VM vm = getVm(); VmHandler.UnLockVm(vm.getId()); endDiskRelatedActions(vm); if (getParameters().getCopyCollapse()) { this.endCopyCollapseOperations(vm); } else { this.endDefaultOps(vm); } setSucceeded(true); }

Target:
protected void EndSuccessfully() { EndActionOnAllImageGroups(); VM vm = getVm(); VmHandler.UnLockVm(vm.getId()); endDiskRelatedActions(vm); if (getParameters().getCopyCollapse()) { this.endCopyCollapseOperations(vm); } else { this.endDefaultOperations(vm); } setSucceeded(true); }
Source:
public Iterator<Comparable> iterator() { final Iterator<Comparable> innerIterator = new StepIterator(this, stepSize); return new Iterator<Comparable>() { @Override public synchronized boolean hasNext() { return innerIterator.hasNext(); } @Override public synchronized Comparable next() { return innerIterator.next(); } @Override public synchronized void remove() { innerIterator.remove(); } }; }

Target:
public Iterator<Comparable> iterator() { return new StepIterator(this, stepSize); }
Source:
public String toString() { return REPR_HEADER + defaultValue + REPR_MAP_OPENING + map.toString() + REPR_MAP_CLOSING; }

Target:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(REPR_HEADER).append(defaultValue).append(REPR_MAP_OPENING).append('{'); for (Map.Entry<String, V> entry : map.entrySet()) { String hostname = entry.getKey(); if (hostname.charAt(0) == '.') { hostname = '*' + hostname; } sb.append(hostname).append('=').append(entry.getValue()).append(", "); } sb.setLength(sb.length() - 2); return sb.append('}').append(REPR_MAP_CLOSING).toString(); }
Source:
public void testLength() { testingClient.server("passwordPolicy").run(session -> { RealmModel realmModel = session.getContext().getRealm(); PasswordPolicyManagerProvider policyManager = session.getProvider(PasswordPolicyManagerProvider.class); realmModel.setPasswordPolicy(PasswordPolicy.parse(session, LengthPasswordPolicyProviderFactory.ID)); Assert.assertEquals("invalidPasswordMinLengthMessage", policyManager.validate("jdoe", "1234567").getMessage()); Assert.assertArrayEquals(new Object[]{8}, policyManager.validate("jdoe", "1234567").getParameters()); assertNull(policyManager.validate("jdoe", "12345678")); realmModel.setPasswordPolicy(PasswordPolicy.parse(session, "length(4)")); Assert.assertEquals("invalidPasswordMinLengthMessage", policyManager.validate("jdoe", "123").getMessage()); Assert.assertArrayEquals(new Object[]{4}, policyManager.validate("jdoe", "123").getParameters()); assertNull(policyManager.validate("jdoe", "1234")); }); }

Target:
public void testLength() { testingClient.server("passwordPolicy").run(session -> { RealmModel realmModel = session.getContext().getRealm(); PasswordPolicyManagerProvider policyManager = session.getProvider(PasswordPolicyManagerProvider.class); realmModel.setPasswordPolicy(PasswordPolicy.parse(session, "length")); Assert.assertEquals("invalidPasswordMinLengthMessage", policyManager.validate("jdoe", "1234567").getMessage()); Assert.assertArrayEquals(new Object[]{8}, policyManager.validate("jdoe", "1234567").getParameters()); assertNull(policyManager.validate("jdoe", "12345678")); realmModel.setPasswordPolicy(PasswordPolicy.parse(session, "length(4)")); Assert.assertEquals("invalidPasswordMinLengthMessage", policyManager.validate("jdoe", "123").getMessage()); Assert.assertArrayEquals(new Object[]{4}, policyManager.validate("jdoe", "123").getParameters()); assertNull(policyManager.validate("jdoe", "1234")); }); }
Source:
public Set<Action> dragonRage(Set<Integer> connectedPlayers) { Set<Action> actionSet = new HashSet<Action>(); for (int dragonId : dragonMap.keySet()) { Dragon d = dragonMap.get(dragonId); for (int playerId : playerMap.keySet()) { Player p = playerMap.get(playerId); if(!isInRange(playerId, dragonId, 2)) { continue; } p.setCurHitPoints(p.getCurHitPoints() - d.getAttackPower()); if (p.getCurHitPoints() <= 0) { DeleteUnitAction dua = new DeleteUnitAction(p.getUnitId()); actionSet.add(dua); removePlayer(p.getUnitId()); } DamageAction da = new DamageAction(p.getUnitId(), d.getAttackPower()); actionSet.add(da); } } return actionSet; }

Target:
public Set<Action> dragonRage(Set<Integer> connectedPlayers) { Set<Action> actionSet = new HashSet<Action>(); for (int dragonId : dragonMap.keySet()) { Dragon d = dragonMap.get(dragonId); for (int playerId : playerMap.keySet()) { Player p = playerMap.get(playerId); if(isInRange(playerId, dragonId, 2)) { p.setCurHitPoints(p.getCurHitPoints() - d.getAttackPower()); if (p.getCurHitPoints() <= 0) { DeleteUnitAction dua = new DeleteUnitAction(p.getUnitId()); actionSet.add(dua); removePlayer(p.getUnitId()); } DamageAction da = new DamageAction(p.getUnitId(), d.getAttackPower()); actionSet.add(da); } } } return actionSet; }
Source:
private static ModuleLoader setupModuleLoader(String modulePath, String... systemPackages) { assert modulePath != null : "modulePath not null"; WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_JBOSS_MODULES_DIR, trimPathToModulesDir(modulePath)); final String classPath = WildFlySecurityManager.getPropertyPrivileged(SYSPROP_KEY_CLASS_PATH, null); try { WildFlySecurityManager.clearPropertyPrivileged(SYSPROP_KEY_CLASS_PATH); WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_MODULE_PATH, modulePath); StringBuilder packages = new StringBuilder("org.jboss.modules,org.jboss.msc,org.jboss.dmr,org.jboss.threads,org.jboss.as.controller.client"); if (systemPackages != null) { for (String packageName : systemPackages) { packages.append(","); packages.append(packageName); } } WildFlySecurityManager.setPropertyPrivileged("jboss.modules.system.pkgs", packages.toString()); URL[] urls = new URL[] {new File(modulePath).toURI().toURL(), new File(modulePath + "/../jboss-modules.jar").toURI().toURL()}; ClassLoader classloader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader()); Class clazz = classloader.loadClass("org.jboss.modules.Module"); return (ModuleLoader)clazz.getMethod("getBootModuleLoader").invoke(clazz); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | MalformedURLException e) { throw new RuntimeException(e); } finally { WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_CLASS_PATH, classPath); } }

Target:
private static ModuleLoader setupModuleLoader(String modulePath, String... systemPackages) { assert modulePath != null : "modulePath not null"; File moduleDir = new File(modulePath); if (!moduleDir.exists() || !moduleDir.isDirectory()) { throw new RuntimeException("The specified module directory " + modulePath + " is invalid or does not exist."); } WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_JBOSS_MODULES_DIR, trimPathToModulesDir(modulePath)); final String classPath = WildFlySecurityManager.getPropertyPrivileged(SYSPROP_KEY_CLASS_PATH, null); try { WildFlySecurityManager.clearPropertyPrivileged(SYSPROP_KEY_CLASS_PATH); WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_MODULE_PATH, modulePath); StringBuilder packages = new StringBuilder("org.jboss.modules,org.jboss.msc,org.jboss.dmr,org.jboss.threads,org.jboss.as.controller.client"); if (systemPackages != null) { for (String packageName : systemPackages) { packages.append(","); packages.append(packageName); } } WildFlySecurityManager.setPropertyPrivileged("jboss.modules.system.pkgs", packages.toString()); return Module.getBootModuleLoader(); } finally { WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_CLASS_PATH, classPath); } }
Source:
public void testFetch() throws JGitInternalException, IOException, GitAPIException, URISyntaxException { Repository db2 = createWorkRepository(); Git git2 = new Git(db2); final Config config = db.getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); URIish uri = new URIish(db2.getDirectory().toURI().toURL()); remoteConfig.addURI(uri); remoteConfig.update(config); RevCommit commit = git2.commit().setMessage("initial commit").call(); git2.tag().setName("tag").call(); Git git1 = new Git(db); assertNull(db.resolve("tag")); assertNull(db.getRef(Constants.R_HEADS + "x")); RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x"); git1.fetch().setRemote("test").setRefSpecs(spec) .call(); assertNotNull(db.getRef(Constants.R_TAGS + "tag")); assertNotNull(db.resolve(commit.getId().getName() + "^{commit}")); assertNotNull(db.getRef(Constants.R_HEADS + "x")); }

Target:
public void testFetch() throws JGitInternalException, IOException, GitAPIException, URISyntaxException { Repository db2 = createWorkRepository(); Git git2 = new Git(db2); final Config config = db.getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); URIish uri = new URIish(db2.getDirectory().toURI().toURL()); remoteConfig.addURI(uri); remoteConfig.update(config); RevCommit commit = git2.commit().setMessage("initial commit").call(); RevTag tag = git2.tag().setName("tag").call(); Git git1 = new Git(db); RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x"); git1.fetch().setRemote("test").setRefSpecs(spec) .call(); assertTrue(commit.getId().equals( db.resolve(commit.getId().getName() + "^{commit}"))); assertTrue(tag.getId().equals(db.resolve(tag.getId().getName()))); }