auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void put(List<Metric> metrics) { requireNotDisposed(); SystemAssert.requireArgument(metrics != null, "Metric list cannot be null."); List<Metric> metricsToPut = new ArrayList<>(metrics.size()); Set<String> scopesToPut = new HashSet<>(metrics.size()); Set<Metric> scopesAndMetricsNamesToPut = new HashSet<>(metrics.size()); for(Metric metric : metrics) { if(metric.getTags().isEmpty()) { String key = constructKey(metric, null); boolean found = bloomFilter.mightContain(key); if(!found) { metricsToPut.add(metric); } } else { boolean newTags = false; for(Entry<String, String> tagEntry : metric.getTags().entrySet()) { String key = constructKey(metric, tagEntry); boolean found = bloomFilter.mightContain(key); if(!found) { newTags = true; } } if(newTags) { metricsToPut.add(metric); } } String scopeName = metric.getScope(); String metricName = metric.getMetric(); String key = constructScopeOnlyKey(scopeName); boolean found = bloomFilterScopeOnly.mightContain(key); if(!found) { scopesToPut.add(scopeName); } key = constructScopeAndMetricOnlyKey(scopeName, metricName); found = bloomFilterScopeAndMetricOnly.mightContain(key); if(!found) { scopesAndMetricsNamesToPut.add(new Metric(scopeName, metricName)); } } List<Metric> scopesAndMetricsToPut = new ArrayList<>(scopesAndMetricsNamesToPut); implementationSpecificPut(metricsToPut, scopesToPut, scopesAndMetricsToPut); }

Target:
public void put(List<Metric> metrics) { requireNotDisposed(); SystemAssert.requireArgument(metrics != null, "Metric list cannot be null."); List<Metric> metricsToPut = new ArrayList<>(metrics.size()); Set<String> scopesToPut = new HashSet<>(metrics.size()); Set<Pair<String, String>> scopesAndMetricsNamesToPut = new HashSet<>(metrics.size()); for(Metric metric : metrics) { if(metric.getTags().isEmpty()) { String key = constructKey(metric, null); boolean found = bloomFilter.mightContain(key); if(!found) { metricsToPut.add(metric); } } else { boolean newTags = false; for(Entry<String, String> tagEntry : metric.getTags().entrySet()) { String key = constructKey(metric, tagEntry); boolean found = bloomFilter.mightContain(key); if(!found) { newTags = true; } } if(newTags) { metricsToPut.add(metric); } } String scopeName = metric.getScope(); String metricName = metric.getMetric(); String key = constructScopeOnlyKey(scopeName); boolean found = bloomFilterScopeOnly.mightContain(key); if(!found) { scopesToPut.add(scopeName); } key = constructScopeAndMetricOnlyKey(scopeName, metricName); found = bloomFilterScopeAndMetricOnly.mightContain(key); if(!found) { scopesAndMetricsNamesToPut.add(Pair.of(scopeName, metricName)); } } implementationSpecificPut(metricsToPut, scopesToPut, scopesAndMetricsNamesToPut); }
Source:
public Collection<T> queryExpression(final String expr, Collection<T> ret, DBConnection connection){ if (ret == null) { ret = new LinkedList<T>(); } boolean setConnection = connection != PersistentObject.getDefaultConnection(); Stm stm = connection.getStatement(); try (ResultSet res = stm.query(expr)) { log.debug("Executed " + expr); while ((res != null) && (res.next() == true)) { final String id = res.getString(1); T o = (T) load.invoke(null, new Object[] { id }); if (o == null) { continue; } else if (setConnection) { ((PersistentObject) o).setDBConnection(connection); } if (fetchVals.length > 1) { PersistentObject po = (PersistentObject) o; for (int i = 1; i < fetchVals.length; i++) { Object prefetchVal = res.getObject(i + 1); po.putInCache(fetchVals[i], prefetchVal); } } boolean bAdd = true; for (IFilter fi : postQueryFilters) { if (fi.select(o) == false) { bAdd = false; break; } } if (bAdd == true) { ret.add(o); } } return ret; } catch (Exception ex) { ElexisStatus status = new ElexisStatus(ElexisStatus.ERROR, CoreHub.PLUGIN_ID, ElexisStatus.CODE_NONE, "Fehler bei Datenbankabfrage " + ex.getMessage(), ex, ElexisStatus.LOG_ERRORS); log.warn(String.format("Fehler %s bei Datenbankabfrage:\n%s;", ex.getMessage(), expr)); throw new PersistenceException(status); } finally { connection.releaseStatement(stm); } }

Target:
public Collection<T> queryExpression(final String expr, Collection<T> ret, DBConnection connection){ if (ret == null) { ret = new LinkedList<T>(); } boolean setConnection = connection != PersistentObject.getDefaultConnection(); Stm stm = connection.getStatement(); try (ResultSet res = stm.query(expr)) { log.debug("Executed " + expr); while ((res != null) && (res.next() == true)) { final String id = res.getString(1); T o = (T) load.invoke(null, new Object[] { id }); if (o == null) { continue; } else if (setConnection) { ((PersistentObject) o).setDBConnection(connection); } if (fetchVals.length > 1) { PersistentObject po = (PersistentObject) o; for (int i = 1; i < fetchVals.length; i++) { Object prefetchVal = res.getObject(i + 1); po.putInCache(fetchVals[i], prefetchVal); } } boolean bAdd = true; for (IFilter fi : postQueryFilters) { if (fi.select(o) == false) { bAdd = false; break; } } if (bAdd == true) { ret.add(o); } } return ret; } catch (Exception ex) { ElexisStatus status = new ElexisStatus(ElexisStatus.ERROR, CoreHub.PLUGIN_ID, ElexisStatus.CODE_NONE, "Fehler bei Datenbankabfrage " + ex.getMessage(), ex, ElexisStatus.LOG_ERRORS); log.warn("Fehler bei Datenbankabfrage:\n[{};]", ex.getMessage(), expr); throw new PersistenceException(status); } finally { connection.releaseStatement(stm); } }
Source:
private XMLGregorianCalendar getTimestamp() throws DatatypeConfigurationException { DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(System.currentTimeMillis()); return datatypeFactory.newXMLGregorianCalendar(gc); }

Target:
private XMLGregorianCalendar getTimestamp() throws DatatypeConfigurationException { return XMLDateUtil.long2Gregorian(System.currentTimeMillis()); }
Source:
private String getFsCopyStatus() { WebElement copyModalStatusMessage = browser.driver.findElement(By.id("feedback-copy-modal-status")); return copyModalStatusMessage.getText(); }

Target:
private String getFsCopyStatus() { return copyModalStatusMessage.getText(); }
Source:
private void performRecoveredIndexDropActions() { indexesToDropAfterCompletedRecovery.values().forEach( index -> { try { index.drop(); } catch ( Exception e ) { try { index.close(); } catch ( IOException closeException ) { e.addSuppressed( closeException ); } } } ); indexesToDropAfterCompletedRecovery.clear(); }

Target:
private void performRecoveredIndexDropActions() { indexesToDropAfterCompletedRecovery.values().forEach( index -> { try { index.drop(); } catch ( Exception e ) { try { index.close(); } catch ( IOException closeException ) { } } } ); indexesToDropAfterCompletedRecovery.clear(); }
Source:
private void parseDelete(final ReceiveCommand cmd) { RefControl ctl = projectControl.controlForRef(cmd.getRefName()); if (ctl.canDelete()) { } else { if (GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName())) { reject(cmd, "Deleting the project configuration is not allowed"); } else { rp.sendMessage("You need 'Push' rights with the 'Force Push' flag set to delete references." + MESSAGE_FOOTER); reject(cmd, "Current user '" + ctl.getCurrentUser().getUserName() + "' can not delete references"); } } }

Target:
private void parseDelete(final ReceiveCommand cmd) { RefControl ctl = projectControl.controlForRef(cmd.getRefName()); if (ctl.canDelete()) { } else { if (GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName())) { reject(cmd, "Cannot delete project configuration"); } else { addError(Error.DELETE, ctl.getRefName()); reject(cmd, String.format("%s cannot delete references", displayName(destBranchCtl))); } } }
Source:
public static void validateHostName(Boolean clusterMapResolveHostnames, String hostName) { if (clusterMapResolveHostnames) { String fqdn = getFullyQualifiedDomainName(hostName); if (!fqdn.equals(hostName)) { throw new IllegalStateException( "Hostname for AmbryDataNode (" + hostName + ") does not match its fully qualified domain name: " + fqdn); } } }

Target:
public static void validateHostName(Boolean clusterMapResolveHostnames, String hostName) { if (clusterMapResolveHostnames) { String fqdn = getFullyQualifiedDomainName(hostName); if (!fqdn.equals(hostName)) { throw new IllegalArgumentException( "Hostname(" + hostName + ") does not match its fully qualified domain name: " + fqdn); } } }
Source:
private void handleException(final URIish uri, Exception e, String userMessage) { if (uri != null) operationResult.addOperationResult(uri, userMessage); String uriString; if (uri == null) uriString = "retrieving URI failed"; else uriString = uri.toString(); String userMessageForUri = NLS.bind( CoreText.PushOperation_ExceptionOccurredDuringPushOnUriMessage, uriString, userMessage); Activator.logError(userMessageForUri, e); }

Target:
private void handleException(final URIish uri, Exception e, String userMessage) { String uriString; if (uri != null) { operationResult.addOperationResult(uri, userMessage); uriString = uri.toString(); } else uriString = "retrieving URI failed"; String userMessageForUri = NLS.bind( CoreText.PushOperation_ExceptionOccurredDuringPushOnUriMessage, uriString, userMessage); Activator.logError(userMessageForUri, e); }
Source:
private boolean canCloneVolume() { return new Boolean(getDriver().getCapabilities().get(DataStoreCapabilities.CAN_CREATE_VOLUME_FROM_VOLUME.toString())); }

Target:
private boolean canCloneVolume() { return Boolean.valueOf(getDriver().getCapabilities().get(DataStoreCapabilities.CAN_CREATE_VOLUME_FROM_VOLUME.toString())); }
Source:
public ChannelModelTransformer( NumberToShortStringCodec v4Codec, ImageModelTranslator imageTranslator ) { this.v4Codec = v4Codec; this.imageTranslator = imageTranslator; }

Target:
private ChannelModelTransformer( NumberToShortStringCodec v4Codec, ImageModelTranslator imageTranslator ) { this.v4Codec = checkNotNull(v4Codec); this.imageTranslator = checkNotNull(imageTranslator); }
Source:
public static String indexFile(final String filename, final String extension) { return ParsingUtils.appendToPath(filename, extension); }

Target:
private static String indexFile(final String filename, final String extension) { return ParsingUtils.appendToPath(filename, extension); }
Source:
private void resizeRootDisk(VirtualMachineMO vmMo, DiskTO rootDiskTO, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception { Pair<VirtualDisk, String> vdisk = getVirtualDiskInfo(vmMo, rootDiskTO.getPath() + ".vmdk"); assert(vdisk != null); Long reqSize=((VolumeObjectTO)rootDiskTO.getData()).getSize()/1024; VirtualDisk disk = vdisk.first(); if(reqSize > disk.getCapacityInKB()) { VirtualMachineDiskInfo diskInfo = getMatchingExistingDisk(vmMo.getDiskInfoBuilder(), rootDiskTO, hyperHost, context); assert (diskInfo != null); String[] diskChain = diskInfo.getDiskChain(); if(diskChain!=null && diskChain.length>1) { s_logger.error("Unsupported Disk chain length "+ diskChain.length); throw new Exception("Unsupported Disk chain length "+ diskChain.length); } if(diskInfo.getDiskDeviceBusName()==null || !diskInfo.getDiskDeviceBusName().toLowerCase().contains("scsi")) { s_logger.error("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName() ); throw new Exception("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName()); } disk.setCapacityInKB(reqSize); VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec(); deviceConfigSpec.setDevice(disk); deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT); vmConfigSpec.getDeviceChange().add(deviceConfigSpec); if (!vmMo.configureVm(vmConfigSpec)) { throw new Exception("Failed to configure VM for given root disk size. vmName: " + vmMo.getName()); } } }

Target:
private void resizeRootDisk(VirtualMachineMO vmMo, DiskTO rootDiskTO, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception { Pair<VirtualDisk, String> vdisk = getVirtualDiskInfo(vmMo, rootDiskTO.getPath() + ".vmdk"); assert(vdisk != null); Long reqSize=((VolumeObjectTO)rootDiskTO.getData()).getSize()/1024; VirtualDisk disk = vdisk.first(); if (reqSize > disk.getCapacityInKB()) { VirtualMachineDiskInfo diskInfo = getMatchingExistingDisk(vmMo.getDiskInfoBuilder(), rootDiskTO, hyperHost, context); assert (diskInfo != null); String[] diskChain = diskInfo.getDiskChain(); if (diskChain != null && diskChain.length>1) { s_logger.error("Unsupported Disk chain length "+ diskChain.length); throw new Exception("Unsupported Disk chain length "+ diskChain.length); } if (diskInfo.getDiskDeviceBusName() == null || !diskInfo.getDiskDeviceBusName().toLowerCase().startsWith("scsi")) { s_logger.error("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName() ); throw new Exception("Unsupported root disk device bus "+ diskInfo.getDiskDeviceBusName()); } disk.setCapacityInKB(reqSize); VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec(); deviceConfigSpec.setDevice(disk); deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT); vmConfigSpec.getDeviceChange().add(deviceConfigSpec); if (!vmMo.configureVm(vmConfigSpec)) { throw new Exception("Failed to configure VM for given root disk size. vmName: " + vmMo.getName()); } } }
Source:
public List<Object> getContent() { if (this.getJaxbElement()==null) { this.setJaxbElement( Context.getWmlObjectFactory().createCTFootnotes() ); } if (content == null) { content = new ArrayListWml<Object>(this.getJaxbElement()); } return this.content; }

Target:
public List<CTFtnEdn> getContent() { try { CTFootnotes contents = this.getContents(); if (contents==null) { contents = Context.getWmlObjectFactory().createCTFootnotes(); this.setContents(contents); } return contents.getFootnote(); } catch (Docx4JException e) { log.error(e.getMessage(), e); return null; } }
Source:
public void deleteRelatedContent(final Contentlet contentlet, final Relationship relationship, final boolean hasParent, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException,DotContentletStateException { if(!permissionAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)){ throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot edit Contentlet"); } List<Relationship> rels = FactoryLocator.getRelationshipFactory().byContentType(contentlet.getContentType()); if(!rels.contains(relationship)){ throw new DotContentletStateException( "Error deleting existing relationships in contentlet: " + (contentlet != null ? contentlet.getInode() : "Unknown")); } List<Contentlet> cons = relationshipAPI.dbRelatedContent(relationship, contentlet, hasParent); cons = permissionAPI.filterCollection(cons, PermissionAPI.PERMISSION_READ, respectFrontendRoles, user); FactoryLocator.getRelationshipFactory().deleteByContent(contentlet, relationship, cons); if(cons != null) { for (final Contentlet relatedContentlet : cons) { relatedContentlet.setIndexPolicy(contentlet.getIndexPolicyDependencies()); relatedContentlet.setIndexPolicyDependencies(contentlet.getIndexPolicyDependencies()); refreshNoDeps(relatedContentlet); } } if (contentlet.get(CHECKIN_IN_PROGRESS) == null || !contentlet.getBoolProperty(CHECKIN_IN_PROGRESS)) { refreshNoDeps(contentlet); } }

Target:
public void deleteRelatedContent(final Contentlet contentlet, final Relationship relationship, final boolean hasParent, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException,DotContentletStateException { if(!permissionAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)){ throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot edit Contentlet"); } List<Relationship> rels = FactoryLocator.getRelationshipFactory().byContentType(contentlet.getContentType()); if(!rels.contains(relationship)){ throw new DotContentletStateException( "Error deleting existing relationships in contentlet: " + (contentlet != null ? contentlet.getInode() : "Unknown")); } List<Contentlet> cons = relationshipAPI.dbRelatedContent(relationship, contentlet, hasParent); cons = permissionAPI.filterCollection(cons, PermissionAPI.PERMISSION_READ, respectFrontendRoles, user); FactoryLocator.getRelationshipFactory().deleteByContent(contentlet, relationship, cons); if(cons != null) { for (final Contentlet relatedContentlet : cons) { relatedContentlet.setIndexPolicy(contentlet.getIndexPolicyDependencies()); relatedContentlet.setIndexPolicyDependencies(contentlet.getIndexPolicyDependencies()); refreshNoDeps(relatedContentlet); } } if (!contentlet.getBoolProperty(CHECKIN_IN_PROGRESS)) { refreshNoDeps(contentlet); } }
Source:
static ParameterizedTypeName get(ParameterizedType type, Map<Type, TypeVariableName> map) { ParameterizedType toTest = type; Deque<ParameterizedType> enclosingStack = new ArrayDeque<ParameterizedType>(); do { enclosingStack.push(toTest); toTest = (toTest.getOwnerType() instanceof ParameterizedType) && !Modifier.isFinal(((Class<?>) type.getRawType()).getModifiers()) ? (ParameterizedType) toTest.getOwnerType() : null; } while (toTest != null); ParameterizedTypeName paramTypeName = null; while (!enclosingStack.isEmpty()) { ParameterizedType ownerType = enclosingStack.pop(); ClassName rawType = ClassName.get((Class<?>) type.getRawType()); List<TypeName> typeArguments = TypeName.list(ownerType.getActualTypeArguments(), map); paramTypeName = (paramTypeName != null) ? paramTypeName.nestedClass(rawType.simpleName(), typeArguments) : new ParameterizedTypeName(rawType, typeArguments); } return paramTypeName; }

Target:
static ParameterizedTypeName get(ParameterizedType type, Map<Type, TypeVariableName> map) { ClassName rawType = ClassName.get((Class<?>) type.getRawType()); ParameterizedType ownerType = (type.getOwnerType() instanceof ParameterizedType) && !Modifier.isStatic(((Class<?>) type.getRawType()).getModifiers()) ? (ParameterizedType) type.getOwnerType() : null; List<TypeName> typeArguments = TypeName.list(type.getActualTypeArguments(), map); return (ownerType != null) ? get(ownerType, map).nestedClass(rawType.simpleName(), typeArguments) : new ParameterizedTypeName(rawType, typeArguments); }
Source:
public boolean hasCredentials() { OAuth2AuthzSession storedAccount = sessionStore.read(AuthEndPoints.NAME); return storedAccount != null; }

Target:
public boolean hasCredentials() { return sessionStore.read(AuthData.NAME) != null; }
Source:
public Set<Stream> getResultStreams() { Set<Stream> streams = new HashSet<Stream>(); streams.add(this.resultStream); return streams; }

Target:
public Set<Stream> getResultStreams() { Set<Stream> streams = ImmutableSet.of(this.resultStream); return streams; }
Source:
public void init() { super.init(); connectSensorsAsync(); ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); }

Target:
public void init() { super.init(); connectSensorsAsync(); setAttribute(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING); }
Source:
public void refresh() { final Set<DRepresentation> representationsToDelete = new HashSet<DRepresentation>(); Iterator<DRepresentation> it = getAllRepresentations().iterator(); while (it.hasNext()) { final DRepresentation representation = it.next(); if (representation instanceof DSemanticDecorator) { if (DialectManager.INSTANCE.isRepresentationConsideredAsDangling(representation)) { representationsToDelete.add(representation); } } if (!representationsToDelete.contains(representation)) { representation.refresh(); } } it = representationsToDelete.iterator(); while (it.hasNext()) { final EObject next = it.next(); final Session session; if (next instanceof DSemanticDecorator) { session = SessionManager.INSTANCE.getSession(((DSemanticDecorator) next).getTarget()); } else { session = SessionManager.INSTANCE.getSession(next); } SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(next).eDelete(next, session != null ? session.getSemanticCrossReferencer() : null); } }

Target:
public void refresh() { final Set<DRepresentation> representationsToDelete = new HashSet<DRepresentation>(); Iterator<DRepresentation> it = getAllRepresentations().iterator(); while (it.hasNext()) { final DRepresentation representation = it.next(); if (representation instanceof DSemanticDecorator && ((DSemanticDecorator) representation).getTarget() == null) { representationsToDelete.add(representation); } if (!representationsToDelete.contains(representation)) { representation.refresh(); } } it = representationsToDelete.iterator(); while (it.hasNext()) { final EObject next = it.next(); final Session session; if (next instanceof DSemanticDecorator) { session = SessionManager.INSTANCE.getSession(((DSemanticDecorator) next).getTarget()); } else { session = SessionManager.INSTANCE.getSession(next); } SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(next).eDelete(next, session != null ? session.getSemanticCrossReferencer() : null); } }
Source:
public void serialize(Trigger trigger, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("id", trigger.getId().toString()); jgen.writeStringField("name", trigger.getName()); jgen.writeStringField("type", trigger.getType().name()); ValueType type = ValueType.value(trigger.getThreshold()); switch (type) { case INT: case LONG: jgen.writeNumberField("thresholdLong", trigger.getThreshold().longValue()); jgen.writeNumberField("threshold", trigger.getThreshold().doubleValue()); break; case DOUBLE: jgen.writeNumberField("threshold", trigger.getThreshold().doubleValue()); break; default: throw new IllegalStateException(); } if(trigger.getSecondaryThreshold() != null) { ValueType type2 = ValueType.value(trigger.getSecondaryThreshold()); switch (type2) { case INT: case LONG: jgen.writeNumberField("secondaryThresholdLong", trigger.getSecondaryThreshold().longValue()); jgen.writeNumberField("secondaryThreshold", trigger.getSecondaryThreshold().doubleValue()); break; case DOUBLE: jgen.writeNumberField("secondaryThreshold", trigger.getSecondaryThreshold().doubleValue()); break; default: throw new IllegalStateException(); } } if(trigger.getInertia() != null) { jgen.writeNumberField("inertia", trigger.getInertia()); } jgen.writeEndObject(); }

Target:
public void serialize(Trigger trigger, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("id", trigger.getId().toString()); jgen.writeStringField("name", trigger.getName()); jgen.writeStringField("type", trigger.getType().name()); ValueType type = ValueType.value(trigger.getThreshold()); switch (type) { case LONG: jgen.writeNumberField("thresholdLong", trigger.getThreshold().longValue()); jgen.writeNumberField("threshold", trigger.getThreshold().doubleValue()); break; case DOUBLE: jgen.writeNumberField("threshold", trigger.getThreshold().doubleValue()); break; default: throw new IllegalStateException(); } if(trigger.getSecondaryThreshold() != null) { ValueType type2 = ValueType.value(trigger.getSecondaryThreshold()); switch (type2) { case LONG: jgen.writeNumberField("secondaryThresholdLong", trigger.getSecondaryThreshold().longValue()); jgen.writeNumberField("secondaryThreshold", trigger.getSecondaryThreshold().doubleValue()); break; case DOUBLE: jgen.writeNumberField("secondaryThreshold", trigger.getSecondaryThreshold().doubleValue()); break; default: throw new IllegalStateException(); } } if(trigger.getInertia() != null) { jgen.writeNumberField("inertia", trigger.getInertia()); } jgen.writeEndObject(); }
Source:
public boolean sendCommand(VeluxBridge bridge, int nodeId, VeluxProductPosition value) { logger.trace("sendCommand(nodeId={},value={}) called.", nodeId, value); SendCommand bcp = bridge.bridgeAPI().sendCommand(); int veluxValue = value.getPositionAsVeluxType(); bcp.setNodeAndMainParameter(nodeId, veluxValue); if ((bridge.bridgeCommunicate(bcp)) && (bcp.isCommunicationSuccessful())) { logger.debug("sendCommand() finished successfully."); return true; } else { logger.trace("sendCommand() finished with failure."); return false; } }

Target:
public boolean sendCommand(VeluxBridge bridge, int nodeId, VeluxProductPosition value) { logger.trace("sendCommand(nodeId={},value={}) called.", nodeId, value); SendCommand bcp = bridge.bridgeAPI().sendCommand(); int veluxValue = value.getPositionAsVeluxType(); bcp.setNodeAndMainParameter(nodeId, veluxValue); if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) { logger.debug("sendCommand() finished successfully."); return true; } else { logger.trace("sendCommand() finished with failure."); return false; } }
Source:
public long getPreciseDateFor(JobState state) { Date date = instance.getStartedDateFor(state); if (date != null) { return date.getTime(); } return -1; }

Target:
private long getPreciseDateFor(JobState state) { Date date = instance.getStartedDateFor(state); if (date != null) { return date.getTime(); } return -1; }
Source:
protected S getNext() { do { if (currentIterator == null) { if (complete) { break; } if (cacheTopology != null) { try { int nextTopology = cacheTopology.getTopologyId() + 1; log.tracef("Waiting for topology %d to continue iterator operation with segments %s", nextTopology, segmentsToUse); stateTransferLock.topologyFuture(nextTopology).get(timeout, timeoutUnit); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new CacheException(e); } } cacheTopology = dm.getCacheTopology(); log.tracef("Creating rehash iterator for segments %s using topology id: %d", segmentsToUse, cacheTopology.getTopologyId()); currentIterator = nonRehashRemoteIterator(cacheTopology.getReadConsistentHash(), segmentsToUse, receivedKeys::get, publisherDecorator(completedHandler, lostSegments -> { }, k -> { Set<Object> set = receivedKeys.get(keyPartitioner.getSegment(k)); if (set != null) { set.add(k); } }), intermediateOperations); } if (currentIterator.hasNext()) { return currentIterator.next(); } else { currentIterator = null; } } while (!segmentsToUse.isEmpty()); complete = true; return null; }

Target:
protected S getNext() { while (true){ CloseableIterator<S> iterator = currentIterator; if (iterator != null && iterator.hasNext()) { return iterator.next(); } if (segmentsToUse.isEmpty()) { return null; } if (iterator != null) { try { int nextTopology = cacheTopology.getTopologyId() + 1; log.tracef("Waiting for topology %d to continue iterator operation with segments %s", nextTopology, segmentsToUse); stateTransferLock.topologyFuture(nextTopology).get(timeout, timeoutUnit); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new CacheException(e); } } cacheTopology = dm.getCacheTopology(); log.tracef("Creating non-rehash iterator for segments %s using topology id: %d", segmentsToUse, cacheTopology.getTopologyId()); currentIterator = nonRehashRemoteIterator(cacheTopology.getReadConsistentHash(), segmentsToUse, receivedKeys::get, publisherDecorator(completedHandler, lostSegments -> { }, k -> { Set<Object> set = receivedKeys.get(keyPartitioner.getSegment(k)); if (set != null) { set.add(k); } }), intermediateOperations); } }
Source:
public void setUp() throws Exception { String chromosome = "1"; long start = 10000000000L; long end = 10000000005L; String reference = "A"; String alternate = "T"; String vepVersion = "88"; String vepCacheVersion = "89"; String mainId = "rs1"; testVariantEntity = new VariantWithSamplesAndAnnotation(chromosome, start, end, reference, alternate, mainId); Annotation variantAnnotation = new Annotation(chromosome, start, end, vepVersion, vepCacheVersion, Collections .singleton(new Xref(GENE_ID, "HGNC")), null); testVariantEntity.setAnnotation(variantAnnotation); List<VariantWithSamplesAndAnnotation> variantEntities = Collections.singletonList(testVariantEntity); List<String> geneIds = new ArrayList<>(); geneIds.add(GENE_ID); given(service.findByGenesAndComplexFilters(eq(geneIds), any(), any(), any(), any())).willReturn(variantEntities); given(service.countByGenesAndComplexFilters(eq(geneIds), any())).willReturn(1L); }

Target:
public void setUp() throws Exception { String chromosome = "1"; long start = 10000000000L; long end = 10000000005L; String reference = "A"; String alternate = "T"; String vepVersion = "88"; String vepCacheVersion = "89"; testVariantEntity = new VariantWithSamplesAndAnnotation(chromosome, start, end, reference, alternate, MAIN_ID); Annotation variantAnnotation = new Annotation(chromosome, start, end, vepVersion, vepCacheVersion, Collections .singleton(new Xref(GENE_ID, "HGNC")), null); testVariantEntity.setAnnotation(variantAnnotation); List<VariantWithSamplesAndAnnotation> variantEntities = Collections.singletonList(testVariantEntity); List<String> geneIds = new ArrayList<>(); geneIds.add(GENE_ID); given(service.findByGenesAndComplexFilters(eq(geneIds), any(), any(), any(), any())).willReturn(variantEntities); given(service.countByGenesAndComplexFilters(eq(geneIds), any())).willReturn(1L); }
Source:
public ASTNode visit(SetBuiltin node, Void _) { ArrayList<Term> items = new ArrayList<>(); for (Term element : node.elements()) { items.add(KApp.of(DataStructureSort.DEFAULT_SET_ITEM_LABEL, (Term) this.visitNode(element))); } Collections.sort(items, unparserLexicalComparator); for (Term base : node.baseTerms()) { items.add((Term)this.visitNode(base)); } if(items.size()==0){ return KApp.of(DataStructureSort.DEFAULT_SET_UNIT_LABEL); } Term basedKapp = items.get(items.size()-1); for(int i = items.size()-2; i >= 0; --i){ ArrayList<Term> tempTerm = new ArrayList<Term>(); tempTerm.add(items.get(i)); tempTerm.add(basedKapp); basedKapp = new KApp(new KLabelConstant(DataStructureSort.DEFAULT_SET_LABEL),new KList(tempTerm)); } return basedKapp; }

Target:
public ASTNode visit(SetBuiltin node, Void _) { return ((SetBuiltin)super.visit(node, _)).toKApp(context); }
Source:
public String getProxyHost() { if (proxyHost != null) { return proxyHost; } else { return getProxyHostProperty(); } }

Target:
public String getProxyHost() { return (proxyHost != null) ? proxyHost : getProxyHostProperty(); }
Source:
public void testSharedPreferencesClearedAfterLoggingException() { CrashReporter.storeUnhandledException(exception); assertTrue(!sharedPreferences.getString(CrashReporter.EXCEPTION_FOR_REPORT, "").isEmpty()); CrashReporter.sendUnhandledCaughtException(); assertTrue(sharedPreferences.getString(CrashReporter.EXCEPTION_FOR_REPORT, "").isEmpty()); }

Target:
public void testSharedPreferencesClearedAfterLoggingException() { CrashReporter.storeUnhandledException(exception); assertFalse(sharedPreferences.getString(CrashReporter.EXCEPTION_FOR_REPORT, "").isEmpty()); CrashReporter.sendUnhandledCaughtException(); assertTrue(sharedPreferences.getString(CrashReporter.EXCEPTION_FOR_REPORT, "").isEmpty()); }
Source:
public static Collection<Supplier<ByteArray>> data() throws IOException { fixture = prepareDirectoryAndPageCache( ByteArrayTest.class ); PageCache pageCache = fixture.pageCache; File dir = fixture.directory; NumberArrayFactory autoWithPageCacheFallback = autoWithPageCacheFallback( pageCache, dir ); NumberArrayFactory pageCacheArrayFactory = new PageCachedNumberArrayFactory( pageCache, dir ); int chunkSize = LENGTH / 10; return Arrays.asList( () -> HEAP.newByteArray( LENGTH, DEFAULT ), () -> HEAP.newDynamicByteArray( chunkSize, DEFAULT ), () -> OFF_HEAP.newByteArray( LENGTH, DEFAULT ), () -> OFF_HEAP.newDynamicByteArray( chunkSize, DEFAULT ), () -> AUTO.newByteArray( LENGTH, DEFAULT ), () -> AUTO.newDynamicByteArray( chunkSize, DEFAULT ), () -> autoWithPageCacheFallback.newByteArray( LENGTH, DEFAULT ), () -> autoWithPageCacheFallback.newDynamicByteArray( chunkSize, DEFAULT ), () -> pageCacheArrayFactory.newByteArray( LENGTH, DEFAULT ), () -> pageCacheArrayFactory.newDynamicByteArray( chunkSize, DEFAULT ) ); }

Target:
public static Collection<Supplier<ByteArray>> data() throws IOException { fixture = prepareDirectoryAndPageCache( ByteArrayTest.class ); PageCache pageCache = fixture.pageCache; File dir = fixture.directory; NumberArrayFactory autoWithPageCacheFallback = auto( pageCache, dir ); NumberArrayFactory pageCacheArrayFactory = new PageCachedNumberArrayFactory( pageCache, dir ); int chunkSize = LENGTH / ChunkedNumberArrayFactory.MAGIC_CHUNK_COUNT; return Arrays.asList( () -> HEAP.newByteArray( LENGTH, DEFAULT ), () -> HEAP.newDynamicByteArray( chunkSize, DEFAULT ), () -> OFF_HEAP.newByteArray( LENGTH, DEFAULT ), () -> OFF_HEAP.newDynamicByteArray( chunkSize, DEFAULT ), () -> AUTO_WITHOUT_PAGECACHE.newByteArray( LENGTH, DEFAULT ), () -> AUTO_WITHOUT_PAGECACHE.newDynamicByteArray( chunkSize, DEFAULT ), () -> autoWithPageCacheFallback.newByteArray( LENGTH, DEFAULT ), () -> autoWithPageCacheFallback.newDynamicByteArray( chunkSize, DEFAULT ), () -> pageCacheArrayFactory.newByteArray( LENGTH, DEFAULT ), () -> pageCacheArrayFactory.newDynamicByteArray( chunkSize, DEFAULT ) ); }
Source:
public static String unQuote( String str ) { StringBuilder builder = new StringBuilder( str ); if ( builder.indexOf( "\"\"" ) > 0 && builder.length() > 0 && builder.charAt( 0 ) == '"' && builder.charAt( builder.length() - 1 ) == '"' ) { builder.deleteCharAt( builder.length() - 1 ); builder.deleteCharAt( 0 ); } return builder.toString(); }

Target:
public static String unQuote( String str ) { if ( str.contains( "\"\"" ) && str.length() > 0 && str.startsWith( "\"" ) && str.endsWith( "\"" ) ) { return str.substring( 1, str.length() - 1 ); } return str; }
Source:
public <V> ListenableFuture<V> executeQuery(CqlQuerySpec<V> querySpec) { PreparedStatement statement = statementPreparer.prepare(querySpec); BoundStatement boundStatement = querySpec.bind(statement.bind()); return execute(boundStatement, querySpec.executor(), querySpec.rowStreamAccumulatorFactory().get()); }

Target:
public <V> ListenableFuture<V> executeQuery(CqlQuerySpec<V> querySpec) { PreparedStatement statement = statementPreparer.prepare(querySpec); Statement executableStatement = querySpec.makeExecutableStatement(statement) .setConsistencyLevel(querySpec.queryConsistency()); return execute(executableStatement, querySpec.executor(), querySpec.rowStreamAccumulatorFactory().get()); }
Source:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); context.record( TransformLineageRecorderUtils.oneInToOneOut(config.inputField, config.outputField, "xmlToJson", "Convert XML string to JSON string.`")); }

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); generateOutputSchema(); if (context.getInputSchema() == null || context.getInputSchema().getFields() == null || context.getOutputSchema() == null || context.getOutputSchema().getFields() == null) { return; } List<String> identityFields = context.getInputSchema().getFields().stream().map(Schema.Field::getName) .filter(field -> outputSchema.getField(field) != null && !field.equals(config.inputField)) .collect(Collectors.toList()); List<String> processedFields = new ArrayList<>(TransformLineageRecorderUtils.getFields(context.getOutputSchema())); processedFields.removeAll(identityFields); List<FieldOperation> outputList = new ArrayList<>( TransformLineageRecorderUtils.generateOneToMany(config.inputField, processedFields, "xmlToJson", "Converted XML string to JSON string.")); outputList.addAll(TransformLineageRecorderUtils.generateOneToOnes(identityFields, "identity", TransformLineageRecorderUtils.IDENTITY_TRANSFORM_DESCRIPTION)); context.record(outputList); }
Source:
public void anonymizationWikiEdits() { Credentials credentials = new Credentials(); String timestamp = Long.toString(DateTime.now().getMillis()); String qanon = "QAanon" + timestamp; String passw = "makak"; SignUpUser user = new SignUpUser(qanon, credentials.emailAnonymousUserTestWikia, passw, LocalDate.of(1990, 3, 19)); UserRegistration.registerUserEmailConfirmed(user); new WikiBasePageObject().loginAs(user.getUsername(), user.getPassword(), wikiURL); new ArticleContent(user.getUsername()).push("Test" + timestamp, "AnonymizationTest"); ArticleHistoryPage articleHistoryPage = new ArticleHistoryPage().open("AnonymizationTest"); String id = articleHistoryPage.getHistoryID(user.getUsername()); Assertion.assertTrue(articleHistoryPage.isUserInHistory(user.getUsername())); articleHistoryPage.logOut(); SpecialAnonymizationUserPage anonymizationStaff = new SpecialAnonymizationUserPage().open(); anonymizationStaff.loginAs(User.SUS_STAFF); anonymizationStaff.fillFutureAnon(qanon) .submitAnonymization(); Assertion.assertStringContains(anonymizationStaff.getAnonConfirmation(), qanon); UserProfilePage userProfilePage = new UserProfilePage().open(qanon); articleHistoryPage = new ArticleHistoryPage().open("AnonymizationTest"); Assertion.assertFalse(articleHistoryPage.isUserInHistory(user.getUsername())); ArticleHistoryPage articleHistoryPageID = new ArticleHistoryPage().openArticleId(id); String anonUser = articleHistoryPageID.getAnonByArticleID(); }

Target:
public void anonymizationWikiEdits() { Credentials credentials = new Credentials(); String timestamp = Long.toString(DateTime.now().getMillis()); String qanon = "QAanon" + timestamp; String passw = "makak"; SignUpUser user = new SignUpUser(qanon, credentials.emailAnonymousUserTestWikia, passw, LocalDate.of(1990, 3, 19)); UserRegistration.registerUserEmailConfirmed(user); new WikiBasePageObject().loginAs(user.getUsername(), user.getPassword(), wikiURL); new ArticleContent(user.getUsername()).push("Test" + timestamp, "AnonymizationTest"); ArticleHistoryPage articleHistoryPage = new ArticleHistoryPage().open("AnonymizationTest"); String id = articleHistoryPage.getHistoryID(user.getUsername()); Assertion.assertTrue(articleHistoryPage.isUserInHistory(user.getUsername())); articleHistoryPage.logOut(); SpecialAnonymizationUserPage anonymizationStaff = new SpecialAnonymizationUserPage().open(); anonymizationStaff.loginAs(User.SUS_STAFF); anonymizationStaff.fillFutureAnon(qanon) .submitAnonymization(); Assertion.assertStringContains(anonymizationStaff.getAnonConfirmation(), qanon); articleHistoryPage = new ArticleHistoryPage().open("AnonymizationTest"); Assertion.assertFalse(articleHistoryPage.isUserInHistory(user.getUsername())); }
Source:
public void shouldNotAddRedundantVersions() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); MongoOperations mongoOperations = MongoConfiguration.getMongoOperations(databaseName, mongoConnection, mongoMappingContext); mongoOperations.save(new AnnotationMetadata("70", "72")); String vepCacheVersion = "87"; String vepVersion = "88"; assertStepCompletes(databaseName, vepCacheVersion, vepVersion); List<AnnotationMetadata> annotationMetadatas = mongoOperations.findAll(AnnotationMetadata.class); assertEquals(2, annotationMetadatas.size()); }

Target:
public void shouldNotAddRedundantVersions() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); MongoOperations mongoOperations = MongoConfiguration.getMongoOperations(databaseName, mongoConnection, mongoMappingContext); String vepCacheVersion = "87"; String vepVersion = "88"; mongoOperations.save(new AnnotationMetadata(vepVersion, vepCacheVersion)); assertStepIsComplete(databaseName, vepCacheVersion, vepVersion); List<AnnotationMetadata> annotationMetadataList = mongoOperations.findAll(AnnotationMetadata.class); assertEquals(1, annotationMetadataList.size()); }
Source:
private static void createDummyTrace(String metadata) { try { File dir; dir = new File(tempTraceDir); if (dir.exists()) { deltree(dir); } dir.mkdirs(); File metadataFile; metadataFile = new File(tempTraceDir + "/metadata"); FileWriter fw = new FileWriter(metadataFile); fw.write(metadata); fw.close(); byte magicLE[] = { (byte) 0xC1, (byte) 0x1F, (byte) 0xFC, (byte) 0xC1 }; byte uuid[] = { (byte) 0xb0, 0x4d, 0x39, 0x1b, (byte) 0xe7, 0x36, 0x44, (byte) 0xc1, (byte) 0x8d, (byte) 0x89, 0x4b, (byte) 0xb4, 0x38, (byte) 0x85, 0x7f, (byte) 0x8d }; Event ev = new Event(2, 2); int dataSize = 4096; final int headerSize = 24 + 44; final int packetSize = dataSize + headerSize + 512; final int nbEvents = (dataSize / ev.getSize()) - 1; final int contentSize = (nbEvents * ev.getSize() + headerSize) * 8; ByteBuffer data = ByteBuffer.allocate(packetSize); data.order(ByteOrder.LITTLE_ENDIAN); data.put(magicLE); data.put(uuid); data.putInt(0); data.putLong(0xa500); data.putLong(nbEvents * 0x10000 + 0xa5a6); data.putLong(contentSize); data.putLong(packetSize * 8); data.putLong(0); data.putInt(0); for (int i = 0; i < nbEvents; i++) { ev.setEventTimestamp(i * 0x10000 + 0xa5a5); ev.setEventContent(i); ev.writeEvent(data); } File dummyFile; dummyFile = new File(tempTraceDir + "/dummyChan"); FileOutputStream fos = new FileOutputStream(dummyFile); data.rewind(); fos.getChannel().write(data); fos.close(); } catch (IOException e) { e.printStackTrace(); } finally { } }

Target:
private static void createDummyTrace(String metadata) { try { File dir; dir = new File(tempTraceDir); if (dir.exists()) { deltree(dir); } dir.mkdirs(); File metadataFile; metadataFile = new File(tempTraceDir + "/metadata"); FileWriter fw = new FileWriter(metadataFile); fw.write(metadata); fw.close(); byte magicLE[] = { (byte) 0xC1, (byte) 0x1F, (byte) 0xFC, (byte) 0xC1 }; byte uuid[] = { (byte) 0xb0, 0x4d, 0x39, 0x1b, (byte) 0xe7, 0x36, 0x44, (byte) 0xc1, (byte) 0x8d, (byte) 0x89, 0x4b, (byte) 0xb4, 0x38, (byte) 0x85, 0x7f, (byte) 0x8d }; Event ev = new Event(2, 2); final int nbEvents = (DATA_SIZE / ev.getSize()) - 1; final int contentSize = (nbEvents * ev.getSize() + HEADER_SIZE) * 8; ByteBuffer data = ByteBuffer.allocate(PAKET_SIZE); data.order(ByteOrder.LITTLE_ENDIAN); data.clear(); data.put(magicLE); data.put(uuid); data.putInt(0); data.putLong(0xa500); data.putLong(nbEvents * 0x10000 + 0xa5a6); data.putLong(contentSize); data.putLong(PAKET_SIZE * 8); data.putLong(0); data.putInt(0); for (int i = 0; i < nbEvents; i++) { ev.setEventTimestamp(i * 0x10000 + 0xa5a5); ev.setEventContent(i); ev.writeEvent(data); } File dummyFile; dummyFile = new File(tempTraceDir + "/dummyChan"); FileOutputStream fos = new FileOutputStream(dummyFile); data.flip(); fos.getChannel().write(data); fos.close(); } catch (IOException e) { e.printStackTrace(); } finally { } }
Source:
static boolean isAlgorithmPresent(Properties props) { String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG); String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER, WalkEncryption.Vals.DEFAULT_VERS); String crytoAlgo; String keyAlgo; switch (version) { case WalkEncryption.Vals.DEFAULT_VERS: case WalkEncryption.JGitV1.VERSION: crytoAlgo = profile; keyAlgo = profile; break; case WalkEncryption.JGitV2.VERSION: crytoAlgo = props .getProperty(profile + WalkEncryption.Keys.X_ALGO); keyAlgo = props .getProperty(profile + WalkEncryption.Keys.X_KEY_ALGO); break; default: return false; } try { InsecureCipherFactory.create(keyAlgo); SecretKeyFactory.getInstance(keyAlgo); return true; } catch (Throwable e) { return false; } }

Target:
static boolean isAlgorithmPresent(Properties props) { String profile = props.getProperty(AmazonS3.Keys.CRYPTO_ALG); String version = props.getProperty(AmazonS3.Keys.CRYPTO_VER, WalkEncryption.Vals.DEFAULT_VERS); String cryptoAlgo; String keyAlgo; switch (version) { case WalkEncryption.Vals.DEFAULT_VERS: case WalkEncryption.JGitV1.VERSION: cryptoAlgo = profile; keyAlgo = profile; break; case WalkEncryption.JGitV2.VERSION: cryptoAlgo = props .getProperty(profile + WalkEncryption.Keys.X_ALGO); keyAlgo = props .getProperty(profile + WalkEncryption.Keys.X_KEY_ALGO); break; default: return false; } try { InsecureCipherFactory.create(cryptoAlgo); SecretKeyFactory.getInstance(keyAlgo); return true; } catch (Throwable e) { return false; } }
Source:
public void exempt(Person responsible, String justification) { DateTime when = new DateTime(); DebtInterestCalculator debtInterestCalculator = getDebtInterestCalculator(when); Money dueInterestAmount = new Money(debtInterestCalculator.getDueInterestAmount()); Money dueFineAmount = new Money(debtInterestCalculator.getDueFineAmount()); Money dueAmount = new Money(debtInterestCalculator.getDueAmount()); when = when.plusSeconds(1); if (dueInterestAmount.isPositive()) { FixedAmountInterestExemption fixedAmountInterestExemption = new FixedAmountInterestExemption(this, responsible, dueInterestAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); fixedAmountInterestExemption.setWhenCreated(when); when = when.plusSeconds(1); } if (dueFineAmount.isPositive()) { FixedAmountFineExemption fixedAmountFineExemption = new FixedAmountFineExemption(this, responsible, dueInterestAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); fixedAmountFineExemption.setWhenCreated(when); when = when.plusSeconds(1); } EventExemption eventExemption = new EventExemption(this, responsible, dueAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); eventExemption.setWhenCreated(when); }

Target:
public void exempt(Person responsible, String justification) { DateTime when = new DateTime(); DebtInterestCalculator debtInterestCalculator = getDebtInterestCalculator(when); Money dueInterestAmount = new Money(debtInterestCalculator.getDueInterestAmount()); Money dueFineAmount = new Money(debtInterestCalculator.getDueFineAmount()); Money dueAmount = new Money(debtInterestCalculator.getDueAmount()); if (dueInterestAmount.isPositive()) { FixedAmountInterestExemption fixedAmountInterestExemption = new FixedAmountInterestExemption(this, responsible, dueInterestAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); fixedAmountInterestExemption.setWhenCreated(when); when = when.plusSeconds(1); } if (dueFineAmount.isPositive()) { FixedAmountFineExemption fixedAmountFineExemption = new FixedAmountFineExemption(this, responsible, dueFineAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); fixedAmountFineExemption.setWhenCreated(when); when = when.plusSeconds(1); } if (dueAmount.isPositive()) { EventExemption eventExemption = new EventExemption(this, responsible, dueAmount, EventExemptionJustificationType.CANCELLED, new DateTime(), justification); eventExemption.setWhenCreated(when); } }
Source:
private void checkState() { final EditorSession session = getSession(); if (session.equals(session)) { setEnabled(!session.getCommandRegistry().getCommandHistory().isEmpty()); fire(); } }

Target:
private void checkState() { if (getSession() != null) { setEnabled(!getSession().getCommandRegistry().getCommandHistory().isEmpty()); fire(); } }
Source:
public void testEmptyQuery() throws ErrnoException { for (Network network : getTestableNetworks()) { CountDownLatch latch = new CountDownLatch(1); final int TIMEOUT_MS = 12_000; final String dname = ""; mDns.query(network, dname, CLASS_IN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP, mHandler, answer -> { if (answer == null) { fail("Raw Query empty dname(ROOT) no answer returned"); } try { new CheckedDnsPacket(answer); fail("Raw Query empty dname(ROOT) get valid answer"); } catch (DnsPacket.ParseException e) { e.getMessage().equals("No available answer"); latch.countDown(); } } ); String msg = "Raw query empty dname(ROOT) but no answer after " + TIMEOUT_MS + "ms."; try { assertTrue(msg, latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { } } }

Target:
public void testEmptyQuery() throws ErrnoException { final String dname = ""; final String msg = "Raw query empty dname(ROOT)"; for (Network network : getTestableNetworks()) { final CountDownLatch latch = new CountDownLatch(1); mDns.query(network, dname, CLASS_IN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP, mHandler, answer -> { if (answer == null) { fail(msg + " no answer returned"); } try { assertValidEmptyAnswer(msg, new DnsAnswer(answer)); latch.countDown(); } catch (DnsPacket.ParseException e) { fail(msg + e.getMessage()); } } ); try { assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.", latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { } } }