auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
static List<HivePartition> getPartitionsSample(List<HivePartition> partitions, int sampleSize) { checkArgument(sampleSize > 0, "sampleSize is expected to be equal to or greater than zero"); if (partitions.size() <= sampleSize) { return partitions; } Map<String, Integer> hashes = computeHashes(partitions); List<HivePartition> partitionsSortedByHash = new ArrayList<>(partitions); Comparator<HivePartition> comparator = Comparator .comparingInt((HivePartition partition) -> hashes.get(partition.getPartitionId())) .thenComparing(HivePartition::getPartitionId); partitionsSortedByHash.sort(comparator); return ImmutableList.copyOf(partitionsSortedByHash.subList(0, sampleSize)); }

Target:
static List<HivePartition> getPartitionsSample(List<HivePartition> partitions, int sampleSize) { checkArgument(sampleSize > 0, "sampleSize is expected to be greater than zero"); if (partitions.size() <= sampleSize) { return partitions; } List<HivePartition> result = new ArrayList<>(); int samplesLeft = sampleSize; if (samplesLeft > 0) { HivePartition min = partitions.get(0); HivePartition max = partitions.get(0); for (HivePartition partition : partitions) { if (partition.getPartitionId().compareTo(min.getPartitionId()) < 0) { min = partition; } else if (partition.getPartitionId().compareTo(max.getPartitionId()) > 0) { max = partition; } } result.add(min); samplesLeft--; if (samplesLeft > 0) { result.add(max); samplesLeft--; } } if (samplesLeft > 0) { HashFunction hashFunction = goodFastHash(32); Comparator<Map.Entry<HivePartition, Integer>> hashComparator = Comparator .<Map.Entry<HivePartition, Integer>, Integer>comparing(Map.Entry::getValue) .thenComparing(entry -> entry.getKey().getPartitionId()); partitions.stream() .filter(partition -> !result.contains(partition)) .map(partition -> immutableEntry(partition, hashFunction.hashUnencodedChars(partition.getPartitionId()).asInt())) .sorted(hashComparator) .limit(sampleSize) .forEach(entry -> result.add(entry.getKey())); } return unmodifiableList(result); }
Source:
private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) { IPipelinedTreeContentProvider pipelinedContentProvider; NavigatorContentExtension[] overridingExtensions; for (NavigatorContentExtension theOverridingExtension : theOverridingExtensions) { if (theOverridingExtension.internalGetContentProvider().isPipelined()) { pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtension .internalGetContentProvider(); pipelinedChildren.setContributor(theOverridingExtension .getDescriptor(), firstClassDescriptor); if (elements) { pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren); } else { pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren); } overridingExtensions = theOverridingExtension.getOverridingExtensionsForTriggerPoint(aParent); if (overridingExtensions.length > 0) { pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements); } } } }

Target:
private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) { IPipelinedTreeContentProvider pipelinedContentProvider; NavigatorContentExtension[] overridingExtensions; for (NavigatorContentExtension overridingExtension : theOverridingExtensions) { if (overridingExtension.internalGetContentProvider().isPipelined()) { pipelinedContentProvider = overridingExtension.internalGetContentProvider(); pipelinedChildren.setContributor(overridingExtension.getDescriptor(), firstClassDescriptor); if (elements) { pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren); } else { pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren); } overridingExtensions = overridingExtension.getOverridingExtensionsForTriggerPoint(aParent); if (overridingExtensions.length > 0) { pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements); } } } }
Source:
public boolean chkAuthorization(String userName, Object accessObject, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IDictionary dictionary; String dictionaryId = null; if (accessObject instanceof String) { dictionaryId = (String) accessObject; dictionary = dictonaryManager.getDictionaryDetails(dictionaryId); } else { try { dictionary = (IDictionary) accessObject; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } if (dictionary == null) { throw new QuadrigaAccessException(); } String dictionaryOwner = dictionary.getOwner().getUserName(); if (userName.equals(dictionaryOwner)) { return true; } if (userRoles.length == 0) return false; List<String> roles = Arrays.asList(userRoles); List<IDictionaryCollaborator> dictCollaboratorList = dictonaryManager.showCollaboratingUsers(dictionaryId); if (dictCollaboratorList == null || dictCollaboratorList.isEmpty()) return false; for (IDictionaryCollaborator dictCollaborator : dictCollaboratorList) { String collaboratorName = dictCollaborator.getCollaborator().getUserObj().getUserName(); if (userName != null && userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = dictCollaborator.getCollaborator().getCollaboratorRoles(); if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles != null) { if (roles.contains(collaboratorRoleId)) { return true; } } } } } } return false; }

Target:
public boolean chkAuthorization(String userName, Object accessObject, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IDictionary dictionary; if (accessObject instanceof String) { String dictionaryId = (String) accessObject; dictionary = dictonaryManager.getDictionaryDetails(dictionaryId); } else { try { dictionary = (IDictionary) accessObject; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } if (dictionary == null) { throw new QuadrigaAccessException(); } String dictionaryOwner = dictionary.getOwner().getUserName(); if (userName.equals(dictionaryOwner)) { return true; } if (userRoles.length == 0) return false; List<String> roles = Arrays.asList(userRoles); List<IDictionaryCollaborator> dictCollaboratorList = dictonaryManager .showCollaboratingUsers(dictionary.getDictionaryId()); if (dictCollaboratorList == null || dictCollaboratorList.isEmpty()) return false; for (IDictionaryCollaborator dictCollaborator : dictCollaboratorList) { String collaboratorName = dictCollaborator.getCollaborator().getUserObj().getUserName(); if (userName != null && userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = dictCollaborator.getCollaborator().getCollaboratorRoles(); if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles != null) { if (roles.contains(collaboratorRoleId)) { return true; } } } } } } return false; }
Source:
public TopologyDescriptor generateConfigWithRoleSwitch() { TopologyDescriptor currentConfig = new TopologyDescriptor(topologyConfig); List<ClusterDescriptor> newActiveClusters = new ArrayList<>(); List<ClusterDescriptor> newStandbyClusters = new ArrayList<>(); currentConfig.getActiveClusters().values().forEach(activeCluster -> newStandbyClusters.add(new ClusterDescriptor(activeCluster, ClusterRole.STANDBY))); currentConfig.getStandbyClusters().values().forEach(standbyCluster -> newActiveClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.ACTIVE))); return new TopologyDescriptor(++epoch, newActiveClusters, newStandbyClusters); }

Target:
public TopologyDescriptor generateConfigWithRoleSwitch() { TopologyDescriptor currentConfig = new TopologyDescriptor(topologyConfig); List<ClusterDescriptor> newActiveClusters = new ArrayList<>(); List<ClusterDescriptor> newStandbyClusters = new ArrayList<>(); currentConfig.getActiveClusters().values().forEach(activeCluster -> newStandbyClusters.add(new ClusterDescriptor(activeCluster, ClusterRole.STANDBY))); for (ClusterDescriptor standbyCluster : currentConfig.getStandbyClusters().values()) { if (newActiveClusters.isEmpty()) { newActiveClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.ACTIVE)); } else { newStandbyClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.STANDBY)); } } return new TopologyDescriptor(++configId, newActiveClusters, newStandbyClusters); }
Source:
private String getMessage() { return "Uncovered range found"; }

Target:
private String getMessage() { return "Uncovered range found " + toString(); }
Source:
public void testHandleTransitionValidation__AssigneesNull() throws OseeCoreException { AtsTestUtil.cleanupAndReset("TransitionManagerTest-F"); TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf(); List<IAtsUser> assigneesBefore = teamArt.getAssignees(); MockTransitionHelper helper = new MockTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), AtsTestUtil.getImplementStateDef().getName(), null, null, TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); TransitionResults results01 = new TransitionResults(); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.isEmpty()); results01 = transMgr.handleAll(); transMgr.getTransaction().execute(); Assert.assertTrue(results01.isEmpty()); List<IAtsUser> assigneesAfter = teamArt.getAssignees(); Assert.assertTrue(assigneesAfter.containsAll(assigneesBefore)); Assert.assertTrue(assigneesBefore.containsAll(assigneesAfter)); }

Target:
public void testHandleTransitionValidation__AssigneesNull() throws OseeCoreException { AtsTestUtil.cleanupAndReset("TransitionManagerTest-F"); TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf(); List<IAtsUser> assigneesBefore = teamArt.getAssignees(); Assert.assertTrue(assigneesBefore.size() > 0); MockTransitionHelper helper = new MockTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), AtsTestUtil.getImplementStateDef().getName(), null, null, TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); TransitionResults results01 = new TransitionResults(); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.isEmpty()); results01 = transMgr.handleAll(); transMgr.getTransaction().execute(); Assert.assertTrue(results01.isEmpty()); List<IAtsUser> assigneesAfter = teamArt.getAssignees(); Assert.assertTrue(assigneesAfter.containsAll(assigneesBefore)); Assert.assertTrue(assigneesBefore.containsAll(assigneesAfter)); }
Source:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (!CheckStoragePool()) { return false; } if (validateStoragePoolName()) { return false; } if (!validateStoragePoolTypeChange()) { return false; } if (!CheckStoragePoolNameLengthValid()) { return false; } if (!valdiateComptibilityVersionChange()) { return false; } if (!isNotLocalfsWithDefaultCluster()) { return false; } addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE); return true; }

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (!CheckStoragePool()) { return false; } if (!validateStoragePoolName()) { return false; } if (!validateStoragePoolTypeChange()) { return false; } if (!CheckStoragePoolNameLengthValid()) { return false; } if (!validateCompatibilityVersionChange()) { return false; } if (!isNotLocalfsWithDefaultCluster()) { return false; } addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE); return true; }
Source:
public void testCreateFileHeader_GitLink() throws Exception { ObjectId aId = blob("a\n"); ObjectId bId = blob("b\n"); String diffHeader = makeDiffHeaderModeChange(PATH_A, PATH_A, aId, bId, GITLINK, REGULAR_FILE) + "-Subproject commit " + aId.name() + "\n"; DiffEntry ad = DiffEntry.delete(PATH_A, aId); ad.oldMode = FileMode.GITLINK; DiffEntry abcd = DiffEntry.add(PATH_A, bId); DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 50); FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }

Target:
public void testCreateFileHeader_GitLink() throws Exception { ObjectId aId = blob("a\n"); ObjectId bId = blob("b\n"); String diffHeader = makeDiffHeaderModeChange(PATH_A, PATH_A, aId, bId, GITLINK, REGULAR_FILE) + "-Subproject commit " + aId.name() + "\n"; DiffEntry ad = DiffEntry.delete(PATH_A, aId); ad.oldMode = FileMode.GITLINK; DiffEntry abcd = DiffEntry.add(PATH_A, bId); DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 0); FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }
Source:
public void encodeCompleteResponse(){ HashMap<String,String> entry = new HashMap<>(); entry.put("foo", "bar"); jedis.xadd( "mystream", StreamEntryID.NEW_ENTRY, entry ); String status = jedis.xgroupCreate("mystream", "mygroup", null, false); Object obj = jedis.sendCommand(XINFO, "STREAM", "mystream"); ArrayList encodeObj = (ArrayList)SafeEncoder.encodeObject(obj); assertEquals( 14, encodeObj.size() ); assertEquals( "length", encodeObj.get(0) ); assertEquals( 1L, encodeObj.get(1) ); ArrayList entryAsList = new ArrayList(2); entryAsList.add("foo"); entryAsList.add("bar"); assertEquals( entryAsList, ((ArrayList)encodeObj.get(11)).get(1) ); assertEquals("PONG", SafeEncoder.encodeObject(jedis.sendCommand(PING))); entry.put("foo2", "bar2"); jedis.hset("hash:test:encode", entry); encodeObj = (ArrayList)SafeEncoder.encodeObject(jedis.sendCommand(HGETALL, "hash:test:encode")); assertEquals( 4, encodeObj.size() ); assertEquals( "foo", encodeObj.get(0) ); assertEquals( "foo2", encodeObj.get(2) ); }

Target:
public void encodeCompleteResponse(){ HashMap<String,String> entry = new HashMap<>(); entry.put("foo", "bar"); jedis.xadd( "mystream", StreamEntryID.NEW_ENTRY, entry ); String status = jedis.xgroupCreate("mystream", "mygroup", null, false); Object obj = jedis.sendCommand(XINFO, "STREAM", "mystream"); List encodeObj = (List)SafeEncoder.encodeObject(obj); assertEquals( 14, encodeObj.size() ); assertEquals( "length", encodeObj.get(0) ); assertEquals( 1L, encodeObj.get(1) ); List entryAsList = new ArrayList(2); entryAsList.add("foo"); entryAsList.add("bar"); assertEquals( entryAsList, ((List)encodeObj.get(11)).get(1) ); assertEquals("PONG", SafeEncoder.encodeObject(jedis.sendCommand(PING))); entry.put("foo2", "bar2"); jedis.hset("hash:test:encode", entry); encodeObj = (List)SafeEncoder.encodeObject(jedis.sendCommand(HGETALL, "hash:test:encode")); assertEquals( 4, encodeObj.size() ); assertTrue(encodeObj.contains("foo")); assertTrue(encodeObj.contains("foo2")); }
Source:
private boolean isVolumeEncrypted(Volume volume) throws ReadContentInputStream.ReadContentInputStreamException, IOException, TskCoreException { boolean possiblyEncrypted = true; if (possiblyEncrypted) { calculatedEntropy = EncryptionDetectionTools.calculateEntropy(volume); if (calculatedEntropy >= minimumEntropy) { return true; } } return false; }

Target:
private boolean isVolumeEncrypted(Volume volume) throws ReadContentInputStream.ReadContentInputStreamException, IOException, TskCoreException { if (volume.getFileSystems().isEmpty()) { calculatedEntropy = EncryptionDetectionTools.calculateEntropy(volume); if (calculatedEntropy >= minimumEntropy) { return true; } } return false; }
Source:
public void setUp() throws Exception { String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { isWindows = true; } if (!isWindows) { tempProj = Files.createTempDirectory("temp").toFile(); assertTrue(tempProj.exists()); basicDevProj = new File("../resources/basic-dev-project"); assertTrue(basicDevProj.exists()); FileUtils.copyDirectoryStructure(basicDevProj, tempProj); assertTrue(tempProj.listFiles().length > 0); logFile = new File(basicDevProj, "/logFile.txt"); logFile.createNewFile(); String pluginVersion = System.getProperty("testing"); File pomXML = new File(tempProj, "/pom.xml"); assertTrue(pomXML.exists()); Path path = pomXML.toPath(); Charset charset = StandardCharsets.UTF_8; String content = new String(Files.readAllBytes(path), charset); content = content.replaceAll("SUB_VERION", pluginVersion); Files.write(path, content.getBytes(charset)); } }

Target:
public void setUp() throws Exception { String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { isWindows = true; } if (!isWindows) { tempProj = Files.createTempDirectory("temp").toFile(); assertTrue(tempProj.exists()); basicDevProj = new File("../resources/basic-dev-project"); assertTrue(basicDevProj.exists()); FileUtils.copyDirectoryStructure(basicDevProj, tempProj); assertTrue(tempProj.listFiles().length > 0); logFile = new File(basicDevProj, "/logFile.txt"); logFile.createNewFile(); replaceVersion(); } }
Source:
public String getConfirmationLink() { StringBuilder ref = new StringBuilder(); ref.append(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED).append("?key=").append(regkey); if (institute != null) { ref.append('&').append(Const.ParamsNames.INSTRUCTOR_INSTITUTION).append('=') .append(Sanitizer.sanitizeForUri(institute)); } return ref.toString(); }

Target:
public String getConfirmationLink() { return Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey + (institute == null ? "" : '&' + Const.ParamsNames.INSTRUCTOR_INSTITUTION + '=' + Sanitizer.sanitizeForUri(institute)); }
Source:
public DockerImageName apply(final DockerImageName original) { return null; }

Target:
public DockerImageName apply(final DockerImageName original) { return DockerImageName.parse("transformed-" + original.asCanonicalNameString()); }
Source:
public HandlesEventDispatching getDispatchDelegate() { return null; }

Target:
public HandlesEventDispatching getDispatchDelegate() { return this.container.getDispatchDelegate(); }
Source:
public PhysicalOperation visitExchange(ExchangeNode node, LocalExecutionPlanContext context) { checkArgument(node.getScope() == LOCAL, "Only local exchanges are supported in the local planner"); if (node.getOrderingScheme().isPresent()) { return createLocalMerge(node, context); } else { return createLocalExchange(node, context); } }

Target:
public PhysicalOperation visitExchange(ExchangeNode node, LocalExecutionPlanContext context) { checkArgument(node.getScope() == LOCAL, "Only local exchanges are supported in the local planner"); if (node.getOrderingScheme().isPresent()) { return createLocalMerge(node, context); } return createLocalExchange(node, context); }
Source:
public void write(final IDocumentFragment fragment, final OutputStream out) throws IOException { final org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(); docPrintln(doc, "<?xml version='1.0' encoding='UTF-8'?>"); writeNode(fragment, doc, ""); final PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); printWriter.print(doc.get()); printWriter.flush(); }

Target:
public void write(final IDocumentFragment fragment, final OutputStream out) throws IOException { final org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(); docPrintln(doc, "<?xml version='1.0' encoding='UTF-8'?>"); writeNode(fragment, doc, ""); writeToOutputStream(out, doc); }
Source:
public void testForkEnvironmentNull() throws InvalidScriptException { fe = null; Boolean result = new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd); assertEquals(false, result); }

Target:
public void testForkEnvironmentNull() throws InvalidScriptException { fe = null; Mockito.when(etd.getInternal()).thenReturn(it); Mockito.when(it.getForkEnvironment()).thenReturn(fe); assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd)); }
Source:
public static final Classifier createSpecializedClassifier(final Classifier general, final Classifier parent, final StructuralFeature structuralFeature) { for (final Class<? extends Classifier> c : UNSPECIALIZABLE_CLASSIFIERS) { if (c.isAssignableFrom(general.getClass())) { Application.getInstance().getGUILog() .log("Warning: " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); return null; } } Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent); ArrayList<NamedElement> members = new ArrayList<>(); for(NamedElement ne : specific.getOwnedMember()){ members.add(ne); } for(NamedElement member : members){ if(member instanceof RedefinableElement) { System.out.println(member.getClassType().getName() + " removing " + member.getName()); specific.getOwnedMember().remove(member); member.dispose(); } } specific.getGeneralization().clear(); SpecializeClassifierAction.specialize(specific, general); return specific; }

Target:
public static final Classifier createSpecializedClassifier(final Classifier general, final Classifier parent, final StructuralFeature structuralFeature) { for (final Class<? extends Classifier> c : UNSPECIALIZABLE_CLASSIFIERS) { if (c.isAssignableFrom(general.getClass())) { Application.getInstance().getGUILog() .log("[WARNING] " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); return null; } } Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent); ArrayList<NamedElement> members = new ArrayList<>(); for(NamedElement ne : specific.getOwnedMember()){ members.add(ne); } for(NamedElement member : members){ if(member instanceof RedefinableElement) { specific.getOwnedMember().remove(member); member.dispose(); } } specific.getGeneralization().clear(); SpecializeClassifierAction.specialize(specific, general); return specific; }
Source:
public MultiTreeTransformer(List<Map<String, Object>> initList){ List<MultiTree> newList = new ArrayList<>(); if (initList != null){ for(Map<String, Object> map : initList){ newList.add(transform(map)); } } this.list = newList; }

Target:
public MultiTreeTransformer(List<Map<String, Object>> initList){ if (initList != null){ for(Map<String, Object> map : initList){ this.list.add(transform(map)); } } }
Source:
private void doTest(String rulesJson, int expectedExecuteCount) throws Exception { new Expectations() {{ mockContext.getComponentOutputFields(anyString, anyString); result = new Fields(IotasEvent.IOTAS_EVENT); mockContext.getComponentId(anyInt); result = "componentid"; }}; RulesBoltDependenciesFactory factory = new RulesBoltDependenciesFactory( new RulesProcessorJsonBuilder(rulesJson), RulesBoltDependenciesFactory.ScriptType.SQL); Window windowConfig = factory.createRuleProcessorRuntime().getRulesRuntime().get(0).getRule().getWindow(); final CountDownLatch latch = new CountDownLatch(expectedExecuteCount); WindowRulesBolt wb = new WindowRulesBolt(factory) { @Override public void execute(TupleWindow inputWindow) { super.execute(inputWindow); latch.countDown(); } }; wb.withWindowConfig(windowConfig); WindowedBoltExecutor wbe = new WindowedBoltExecutor(wb); Map<String, Object> conf = wb.getComponentConfiguration(); conf.put("topology.message.timeout.secs", 30); wbe.prepare(conf, mockContext, mockCollector); for (int i = 1; i <= 20; i++) { wbe.execute(getNextTuple(i)); } latch.await(5, TimeUnit.SECONDS); }

Target:
private boolean doTest(String rulesJson, int expectedExecuteCount) throws Exception { new Expectations() {{ mockContext.getComponentOutputFields(anyString, anyString); result = new Fields(IotasEvent.IOTAS_EVENT); mockContext.getComponentId(anyInt); result = "componentid"; }}; RulesBoltDependenciesFactory factory = new RulesBoltDependenciesFactory( new RulesProcessorJsonBuilder(rulesJson), RulesBoltDependenciesFactory.ScriptType.SQL); Window windowConfig = factory.createRuleProcessorRuntime().getRulesRuntime().get(0).getRule().getWindow(); final CountDownLatch latch = new CountDownLatch(expectedExecuteCount); WindowRulesBolt wb = new WindowRulesBolt(factory) { @Override public void execute(TupleWindow inputWindow) { super.execute(inputWindow); latch.countDown(); } }; wb.withWindowConfig(windowConfig); WindowedBoltExecutor wbe = new WindowedBoltExecutor(wb); Map<String, Object> conf = wb.getComponentConfiguration(); conf.put("topology.message.timeout.secs", 30); wbe.prepare(conf, mockContext, mockCollector); for (int i = 1; i <= 20; i++) { wbe.execute(getNextTuple(i)); } return latch.await(5, TimeUnit.SECONDS); }
Source:
private void finishAndGoBackToSource() { if (source != null && source == Source.STATS) { SiteModel site = (SiteModel) getIntent().getSerializableExtra(SITE); ActivityLauncher.viewBlogStats(this, site); } finish(); }

Target:
private void finishAndGoBackToSource() { if (mSource == Source.STATS) { SiteModel site = (SiteModel) getIntent().getSerializableExtra(SITE); mDispatcher.dispatch(SiteActionBuilder.newFetchSiteAction(site)); ActivityLauncher.viewBlogStatsAfterJetpackSetup(this, site); } finish(); }
Source:
public void testNestedPOJOExpression() { Expression expression = createExpression(fqcn, "innerObj.boolVal", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "{$.innerObj.boolVal}", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "$.innerObj.boolVal", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "!{$.innerObj.boolVal}", boolean.class); assertFalse((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "!{$}.innerObj.boolVal", boolean.class); assertFalse((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "{$}.innerObj.boolVal && ({$}.innerObj.intVal == 11)", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "valueOf({$.innerObj.privateIntVal}) + substring({$.innerObj.stringVal}, 2) + {$.innerObj.privateStringVal}.length()", String.class, new String[]{"org.apache.commons.lang3.StringUtils.*", "java.lang.String.valueOf"}); assertEquals("11llo5", expression.execute(testObj)); expression = createExpression(fqcn, "round(pow({$.innerObj.privateFloatVal}, {$.innerObj.privateDoubleVal}))", long.class, new String[] {"java.lang.Math.*"}); assertEquals(46162L, expression.execute(testObj)); }

Target:
public void testNestedPOJOExpression() { Expression expression = createExpression(fqcn, "innerObj.boolVal", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "{$.innerObj.boolVal}", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "$.innerObj.boolVal", boolean.class); assertTrue((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "!{$.innerObj.boolVal}", boolean.class); assertFalse((Boolean)expression.execute(testObj)); expression = createExpression(fqcn, "!{$}.innerObj.boolVal", boolean.class); assertFalse((Boolean)expression.execute(testObj)); }
Source:
public void createAdminAccess() throws Exception { ObjectMapper mapper = new ObjectMapper(); BitstreamFormatRest bitstreamFormatRest = this.createRandomMockBitstreamRest(false); String token = getAuthToken(admin.getEmail(), password); MvcResult mvcResult = getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes(bitstreamFormatRest)).contentType(contentType)) .andExpect(status().isCreated()) .andReturn(); String content = mvcResult.getResponse().getContentAsString(); Map<String, Object> map = mapper.readValue(content, Map.class); String newlyCreatedBitstreamID = String.valueOf(map.get("id")); getClient().perform(get("/api/core/bitstreamformats/" + newlyCreatedBitstreamID)) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$.description", is(bitstreamFormatRest.getDescription()))) .andExpect(jsonPath("$.shortDescription", is(bitstreamFormatRest.getShortDescription()))) .andExpect(jsonPath("$.mimetype", is(bitstreamFormatRest.getMimetype()))) .andExpect(jsonPath("$.type", is("bitstreamformat"))) .andExpect(jsonPath("$._links.self.href", startsWith(REST_SERVER_URL))) .andExpect(jsonPath("$._links.self.href", endsWith("/api/core/bitstreamformats/" + newlyCreatedBitstreamID))); }

Target:
public void createAdminAccess() throws Exception { ObjectMapper mapper = new ObjectMapper(); BitstreamFormatRest bitstreamFormatRest = this.createRandomMockBitstreamRest(false); String token = getAuthToken(admin.getEmail(), password); AtomicReference<Integer> idRef = new AtomicReference<>(); try { MvcResult mvcResult = getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes( bitstreamFormatRest)) .contentType(contentType)) .andExpect(status().isCreated()) .andReturn(); String content = mvcResult.getResponse().getContentAsString(); Map<String, Object> map = mapper.readValue(content, Map.class); String newlyCreatedBitstreamID = String.valueOf(map.get("id")); getClient().perform(get("/api/core/bitstreamformats/" + newlyCreatedBitstreamID)) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( BitstreamFormatMatcher .matchBitstreamFormat(Integer.parseInt(newlyCreatedBitstreamID), bitstreamFormatRest.getMimetype(), bitstreamFormatRest.getDescription(), bitstreamFormatRest.getShortDescription()) ))) .andDo(result -> idRef .set(read(result.getResponse().getContentAsString(), "$.id"))); } finally { BitstreamFormatBuilder.deleteBitstreamFormat(idRef.get()); } }
Source:
public IBlockState getDefaultDisplayTile() { return IC2Plugin.getBlockState("te","mfe"); }

Target:
public IBlockState getDefaultDisplayTile() { return IC2Plugin.getBlockState("te","mfsu"); }
Source:
private TaskInfo.Builder getTaskInfoBuilder(Offer offer, Request request, TaskID taskId, CommandInfo.Builder commandBuilder) { TaskInfo.Builder builder = TaskInfo.newBuilder() .setName("task " + taskId.getValue()) .setTaskId(taskId) .setSlaveId(offer.getSlaveId()) .setCommand(commandBuilder.build()); double cpusNeeded = request.request.cpus; double memNeeded = request.request.mem; for (Resource r : offer.getResourcesList()) { if (r.getName().equals("cpus") && cpusNeeded > 0) { double cpus = Math.min(r.getScalar().getValue(), cpusNeeded); builder.addResources( Resource .newBuilder() .setName("cpus") .setType(Value.Type.SCALAR) .setRole(r.getRole()) .setScalar( Value.Scalar.newBuilder() .setValue(cpus).build()).build()); cpusNeeded -= cpus; } else if (r.getName().equals("mem") && memNeeded > 0) { double mem = Math.min(r.getScalar().getValue(), memNeeded); builder.addResources( Resource .newBuilder() .setName("mem") .setType(Value.Type.SCALAR) .setRole(r.getRole()) .setScalar( Value.Scalar.newBuilder() .setValue(mem).build()).build()); memNeeded -= mem; } else if (cpusNeeded == 0 && memNeeded == 0) { break; } } return builder; }

Target:
private TaskInfo.Builder getTaskInfoBuilder(Offer offer, Request request, TaskID taskId, CommandInfo.Builder commandBuilder) { TaskInfo.Builder builder = TaskInfo.newBuilder() .setName("task " + taskId.getValue()) .setTaskId(taskId) .setSlaveId(offer.getSlaveId()) .setCommand(commandBuilder.build()); double cpusNeeded = request.request.cpus; double memNeeded = (1 + JVM_MEM_OVERHEAD_FACTOR) * request.request.mem; for (Resource r : offer.getResourcesList()) { if (r.getName().equals("cpus") && cpusNeeded > 0) { double cpus = Math.min(r.getScalar().getValue(), cpusNeeded); builder.addResources( Resource .newBuilder() .setName("cpus") .setType(Value.Type.SCALAR) .setRole(r.getRole()) .setScalar( Value.Scalar.newBuilder() .setValue(cpus).build()).build()); cpusNeeded -= cpus; } else if (r.getName().equals("mem") && memNeeded > 0) { double mem = Math.min(r.getScalar().getValue(), memNeeded); builder.addResources( Resource .newBuilder() .setName("mem") .setType(Value.Type.SCALAR) .setRole(r.getRole()) .setScalar( Value.Scalar.newBuilder() .setValue(mem).build()).build()); memNeeded -= mem; } else if (cpusNeeded == 0 && memNeeded == 0) { break; } } return builder; }
Source:
public void tearDown() { if (authenticator != null) ((HasVirtualAuthenticator) driver).removeVirtualAuthenticator(authenticator); }

Target:
public void tearDown() { if (authenticator != null) { ((HasVirtualAuthenticator) driver).removeVirtualAuthenticator(authenticator); } }
Source:
public String getAllowedUnitTypeName() { if(getAllowedUnitType() > UnitType.SIZE || getAllowedUnitType() < 0) { return SPECIAL_UNIT_TYPES.get(getAllowedUnitType()); } else { return UnitType.getTypeDisplayableName(getAllowedUnitType()); } }

Target:
public String getAllowedUnitTypeName() { if(getAllowedUnitType() >= UnitType.SIZE || getAllowedUnitType() < 0) { return SPECIAL_UNIT_TYPES.get(getAllowedUnitType()); } else { return UnitType.getTypeDisplayableName(getAllowedUnitType()); } }
Source:
private void setRepository(@NonNull GitHubRepository repository) { Preconditions.checkNotNull(repository, "Repository cannot be null."); titleTextView.setText(repository.getName()); stargazersTextView.setText("stars: " + repository.getStargazersCount()); forksTextView.setText("forks: " + repository.getForksCount()); request = Glide.with(getContext()) .load(repository.getOwner().getAvatarUrl()) .fitCenter() .crossFade() .placeholder(android.R.drawable.sym_def_app_icon) .into(avatarImageView); }

Target:
private void setRepository(@NonNull GitHubRepository repository) { Preconditions.checkNotNull(repository, "Repository cannot be null."); titleTextView.setText(repository.getName()); stargazersTextView.setText("stars: " + repository.getStargazersCount()); forksTextView.setText("forks: " + repository.getForksCount()); request.set(Glide.with(getContext()) .load(repository.getOwner().getAvatarUrl()) .fitCenter() .crossFade() .placeholder(android.R.drawable.sym_def_app_icon) .into(avatarImageView)); }
Source:
public void testAccept() throws Exception { RejectionPolicy rejectionPolicy = new MessageTimeRejectionPolicyFactory().create( new Period("PT10M") ); Assert.assertTrue(rejectionPolicy.accept(new DateTime().getMillis())); }

Target:
public void testAccept() throws Exception { Period period = new Period("PT10M"); RejectionPolicy rejectionPolicy = new MessageTimeRejectionPolicyFactory().create(period); DateTime now = new DateTime(); DateTime past = now.minus(period).minus(1); DateTime future = now.plus(period).plus(1); Assert.assertTrue(rejectionPolicy.accept(now.getMillis())); Assert.assertFalse(rejectionPolicy.accept(past.getMillis())); Assert.assertTrue(rejectionPolicy.accept(future.getMillis())); Assert.assertFalse(rejectionPolicy.accept(now.getMillis())); }
Source:
public void testSaveBulkNullData() throws Exception { List<Document> documents = new Vector<Document>(); documents.add(new Document(UUID.randomUUID().toString(), System.currentTimeMillis(), mapper.valueToTree(Collections.singletonMap("TEST_NAME", "SINGLE_SAVE_TEST")))); documents.add(new Document(UUID.randomUUID().toString(), System.currentTimeMillis(), null)); queryStore.save(TestUtils.TEST_TABLE_NAME, documents); }

Target:
public void testSaveBulkNullData() throws Exception { List<Document> documents = new Vector<Document>(); documents.add(new Document(UUID.randomUUID().toString(), System.currentTimeMillis(), mapper.valueToTree(Collections.singletonMap("TEST_NAME", "SINGLE_SAVE_TEST")))); documents.add(new Document(UUID.randomUUID().toString(), System.currentTimeMillis(), null)); try { queryStore.save(TestUtils.TEST_TABLE_NAME, documents); } catch (QueryStoreException e) { assertEquals(QueryStoreException.ErrorCode.INVALID_REQUEST, e.getErrorCode()); throw e; } }
Source:
public static Resource getYarnResourcesFromMesosOffers(Collection<Offer> offers) { double cpus = 0.0; double mem = 0.0; for (Protos.Offer offer : offers) { for (Protos.Resource resource : offer.getResourcesList()) { if (resource.getName().equalsIgnoreCase("cpus")) { cpus += resource.getScalar().getValue(); } else if (resource.getName().equalsIgnoreCase("mem")) { mem += resource.getScalar().getValue() / vcoreRatio; } } } return Resource.newInstance((int) mem, (int) cpus); }

Target:
public static Resource getYarnResourcesFromMesosOffers(Collection<Offer> offers) { double cpus = 0.0; double mem = 0.0; for (Protos.Offer offer : offers) { for (Protos.Resource resource : offer.getResourcesList()) { if (resource.getName().equalsIgnoreCase("cpus")) { cpus += resource.getScalar().getValue() / vcoreRatio; } else if (resource.getName().equalsIgnoreCase("mem")) { mem += resource.getScalar().getValue(); } } } return Resource.newInstance((int) mem, (int) cpus); }
Source:
public void should_return_404_when_validating_3ds_flex_credentials_if_gateway_account_does_not_exist() throws Exception{ givenSetup() .body(getCheck3dsConfigPayloadForValidCredentials()) .post(format(VALIDATE_3DS_FLEX_CREDENTIALS_URL, nextLong(1, 99999))) .then() .statusCode(HttpStatus.SC_NOT_FOUND); }

Target:
public void should_return_404_when_validating_3ds_flex_credentials_if_gateway_account_does_not_exist() throws Exception{ givenSetup() .body(getCheck3dsConfigPayloadForValidCredentials()) .post(format(VALIDATE_3DS_FLEX_CREDENTIALS_URL, accountId-1)) .then() .statusCode(HttpStatus.SC_NOT_FOUND); }
Source:
protected boolean canDoAction() { return true; }

Target:
protected boolean canDoAction() { if(getVmDAO().get(getParameters().getVmId()) == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND); } return super.canDoAction(); }
Source:
public Optional<InterceptorChain<Command, CommandResponse>> create(final TypeToken<?> type) { final Class<?> commandClass = type.getRawType(); final boolean isPublicCommand = commandClass.isAnnotationPresent(XKasperPublic.class); SecurityStrategy securityStrategy = isPublicCommand ? new DefaultPublicSecurityStrategy(securityConfiguration) : new DefaultSecurityStrategy(securityConfiguration); final Interceptor<Command, CommandResponse> interceptor = new CommandSecurityInterceptor(securityStrategy); return Optional.of(InterceptorChain.makeChain(interceptor)); }

Target:
public Optional<InterceptorChain<Command, CommandResponse>> create(final TypeToken<?> type) { final Class<?> commandClass = type.getRawType(); final SecurityStrategy securityStrategy; if (commandClass.isAnnotationPresent(XKasperPublic.class)) { securityStrategy = new DefaultPublicSecurityStrategy(securityConfiguration); } else { securityStrategy = new DefaultSecurityStrategy(securityConfiguration); } final Interceptor<Command, CommandResponse> interceptor = new CommandSecurityInterceptor<>(securityStrategy); return Optional.of(InterceptorChain.makeChain(interceptor)); }
Source:
private boolean moveFileToBackup(File file) { log("Moving file as backup"); String backupFilename = getBackupFilename(file.getName()); File backup = new File(file.getParent(), backupFilename); return moveFile(file.toPath(), backup.toPath()); }

Target:
private void moveFileToBackup(File file) throws IOException { log("Moving file as backup"); String backupFilename = getBackupFilename(file.getName()); File backup = new File(file.getParent(), backupFilename); JarUpdaterFileHandler.moveFileWithReplaceExisting(file.toPath(), backup.toPath()); }
Source:
private int calculateDamageLevel(Entity entity) { if((entity instanceof GunEmplacement) && entity.isDestroyed()) { return Entity.DMG_CRIPPLED; } if(entity.isAirborne() && entity.getCrew().isEjected()) { return Math.max(Entity.DMG_HEAVY, entity.getDamageLevel(false)); } int calculatedDamageLevel = entity.getDamageLevel(); if(calculatedDamageLevel == Entity.DMG_CRIPPLED) { if(entity.getArmorRemainingPercent() == 1.0) { calculatedDamageLevel = Entity.DMG_NONE; } } return calculatedDamageLevel; }

Target:
private int calculateDamageLevel(Entity entity) { if((entity instanceof GunEmplacement) && entity.isDestroyed()) { return Entity.DMG_CRIPPLED; } if(entity.isAirborne() && entity.getCrew().isEjected()) { return Math.max(Entity.DMG_HEAVY, entity.getDamageLevel(false)); } int calculatedDamageLevel = entity.getDamageLevel(); if(calculatedDamageLevel == Entity.DMG_CRIPPLED) { if(entity.getArmorRemainingPercent() >= 1.0) { calculatedDamageLevel = Entity.DMG_NONE; } } return calculatedDamageLevel; }
Source:
public Long getStartTime() { return (task != null) ? task.getGenStartTimeAsLong() : null; }

Target:
public Long getStartTime() { return (task != null) ? task.getStartTimeAsLong() : null; }
Source:
public void shouldCloseSideEffectsUsingWithRemote() throws Exception { final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal().withRemote(conf); g.addV("person").property("age", 20).iterate(); g.addV("person").property("age", 10).iterate(); final GraphTraversal traversal = g.V().aggregate("a").aggregate("b"); traversal.iterate(); final DriverRemoteTraversalSideEffects se = (DriverRemoteTraversalSideEffects) traversal.asAdmin().getSideEffects(); final BulkSet sideEffects = se.get("a"); assertThat(sideEffects.isEmpty(), is(false)); se.close(); assertNull(se.get("b")); final Set<String> localSideEffectKeys = se.keys(); assertEquals(1, localSideEffectKeys.size()); final BulkSet localSideEffects = se.get("a"); assertThat(localSideEffects.isEmpty(), is(false)); final Cluster cluster = Cluster.build("localhost").create(); final Client client = cluster.connect(); Field field = DriverRemoteTraversalSideEffects.class.getDeclaredField("serverSideEffect"); field.setAccessible(true); UUID serverSideEffectId = (UUID) field.get(se); final Map<String, String> aliases = new HashMap<>(); aliases.put("g", "g"); final RequestMessage msg = RequestMessage.build(Tokens.OPS_GATHER) .addArg(Tokens.ARGS_SIDE_EFFECT, serverSideEffectId) .addArg(Tokens.ARGS_SIDE_EFFECT_KEY, "b") .addArg(Tokens.ARGS_ALIASES, aliases) .processor("traversal").create(); boolean error; try { client.submitAsync(msg).get().one(); error = false; } catch (Exception ex) { error = true; } assertThat(error, is(true)); }

Target:
public void shouldCloseSideEffectsUsingWithRemote() throws Exception { final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal().withRemote(conf); g.addV("person").property("age", 20).iterate(); g.addV("person").property("age", 10).iterate(); final GraphTraversal traversal = g.V().aggregate("a").aggregate("b"); traversal.iterate(); final DriverRemoteTraversalSideEffects se = (DriverRemoteTraversalSideEffects) traversal.asAdmin().getSideEffects(); final BulkSet sideEffects = se.get("a"); assertThat(sideEffects.isEmpty(), is(false)); se.close(); assertNull(se.get("b")); final Set<String> localSideEffectKeys = se.keys(); assertEquals(1, localSideEffectKeys.size()); final BulkSet localSideEffects = se.get("a"); assertThat(localSideEffects.isEmpty(), is(false)); final Cluster cluster = Cluster.build("localhost").create(); final Client client = cluster.connect(); final Field field = DriverRemoteTraversalSideEffects.class.getDeclaredField("serverSideEffect"); field.setAccessible(true); final UUID serverSideEffectId = (UUID) field.get(se); final Map<String, String> aliases = new HashMap<>(); aliases.put("g", "g"); final RequestMessage msg = RequestMessage.build(Tokens.OPS_GATHER) .addArg(Tokens.ARGS_SIDE_EFFECT, serverSideEffectId) .addArg(Tokens.ARGS_SIDE_EFFECT_KEY, "b") .addArg(Tokens.ARGS_ALIASES, aliases) .processor("traversal").create(); boolean error; try { client.submitAsync(msg).get().one(); error = false; } catch (Exception ex) { error = true; } assertThat(error, is(true)); }
Source:
private boolean canDeleteWorkflow(String path) { Optional<BioWorkflow> workflow = workflowDAO.findByPath(path, false, BioWorkflow.class); if (workflow.isPresent()) { return Objects.equals(workflow.get().getMode(), WorkflowMode.STUB); } else { return false; } }

Target:
private boolean canDeleteWorkflow(String path) { Optional<BioWorkflow> workflow = workflowDAO.findByPath(path, false, BioWorkflow.class); if (workflow.isPresent()) { return workflow.get().getMode() == WorkflowMode.STUB; } return false; }
Source:
protected void run() throws Exception { final TreeWalk walk = new TreeWalk(db); final ObjectReader reader = walk.getObjectReader(); final MutableObjectId buf = new MutableObjectId(); final ZipOutputStream out = new ZipOutputStream(System.out); if (tree == null) throw die(CLIText.get().treeIsRequired); if (reader == null) throw die("BUG: no object reader for tree walker?"); walk.reset(); walk.addTree(tree); walk.setRecursive(true); while (walk.next()) { String name = walk.getPathString(); final FileMode mode = walk.getFileMode(0); walk.getObjectId(buf, 0); if (mode == FileMode.TREE) name += "/"; final ZipEntry entry = new ZipEntry(name); final ObjectLoader loader = reader.open(buf); entry.setSize(loader.getSize()); out.putNextEntry(entry); loader.copyTo(out); if (mode != FileMode.REGULAR_FILE && mode != FileMode.TREE) System.err.println(MessageFormat.format( CLIText.get().archiveEntryModeIgnored, name)); } out.close(); }

Target:
protected void run() throws Exception { final TreeWalk walk = new TreeWalk(db); final ObjectReader reader = walk.getObjectReader(); final MutableObjectId idBuf = new MutableObjectId(); final ZipOutputStream out = new ZipOutputStream(outs); if (tree == null) throw die(CLIText.get().treeIsRequired); walk.reset(); walk.addTree(tree); walk.setRecursive(true); while (walk.next()) { final String name = walk.getPathString(); final FileMode mode = walk.getFileMode(0); walk.getObjectId(idBuf, 0); if (mode == FileMode.TREE) continue; final ZipEntry entry = new ZipEntry(name); final ObjectLoader loader = reader.open(idBuf); entry.setSize(loader.getSize()); out.putNextEntry(entry); loader.copyTo(out); if (mode != FileMode.REGULAR_FILE) System.err.println(MessageFormat.format( CLIText.get().archiveEntryModeIgnored, name)); } out.close(); }
Source:
public void fetchCurrentTheme() { final String siteId = getBlogId(); WordPress.getRestClientUtilsV1_1().getCurrentTheme(siteId, new Listener() { @Override public void onResponse(JSONObject response) { try { mCurrentTheme = Theme.fromJSONV1_1(response); if (mCurrentTheme != null) { mCurrentTheme.setIsCurrent(true); mCurrentTheme.save(); WordPress.wpDB.setCurrentTheme(siteId, mCurrentTheme.getId()); if (mThemeBrowserFragment != null) { mThemeBrowserFragment.setRefreshing(false); if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getId()); } } } } catch (JSONException e) { AppLog.e(T.THEMES, e); } } }, new ErrorListener() { @Override public void onErrorResponse(VolleyError response) { String themeId = WordPress.wpDB.getCurrentThemeId(siteId); mCurrentTheme = WordPress.wpDB.getTheme(siteId, themeId); if (mCurrentTheme != null) { if (mThemeBrowserFragment != null) { if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getId()); } } } } } ); }

Target:
public void fetchCurrentTheme() { final String siteId = getBlogId(); WordPress.getRestClientUtilsV1_1().getCurrentTheme(siteId, new Listener() { @Override public void onResponse(JSONObject response) { try { mCurrentTheme = Theme.fromJSONV1_1(response); if (mCurrentTheme != null) { mCurrentTheme.setIsCurrent(true); mCurrentTheme.save(); WordPress.wpDB.setCurrentTheme(siteId, mCurrentTheme.getId()); if (mThemeBrowserFragment != null) { mThemeBrowserFragment.setRefreshing(false); if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getId()); } } } } catch (JSONException e) { AppLog.e(T.THEMES, e); } } }, new ErrorListener() { @Override public void onErrorResponse(VolleyError response) { String themeId = WordPress.wpDB.getCurrentThemeId(siteId); mCurrentTheme = WordPress.wpDB.getTheme(siteId, themeId); if (mCurrentTheme != null && mThemeBrowserFragment != null) { if (mThemeBrowserFragment.getCurrentThemeTextView() != null) { mThemeBrowserFragment.getCurrentThemeTextView().setText(mCurrentTheme.getName()); mThemeBrowserFragment.setCurrentThemeId(mCurrentTheme.getId()); } } } } ); }