auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean select(Viewer viewer, Object parentElement, Object element) { try { if (element instanceof IProject) { IProject project = (IProject) element; if (project.hasNature(TmfProjectNature.ID) && TmfProjectModelHelper.isShadowProject(project)) { return false; } } } catch (CoreException e) { } return true; }

Target:
public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IProject) { IProject project = (IProject) element; if (TmfProjectModelHelper.isShadowProject(project)) { return false; } } return true; }
Source:
public void updateBatchSchedule(RequestExecution requestExecution) throws AmbariException { BatchRequest lastCompletedBatchRequest = calculateLastCompletedBatch(requestExecution); if (requestExecution.getStatus().equals(SCHEDULED.name())) { long startingBatchId = lastCompletedBatchRequest == null? 1L : lastCompletedBatchRequest.getOrderId() + 1; scheduleBatch(requestExecution, startingBatchId); } else if (requestExecution.getStatus().equals(PAUSED.name()) || requestExecution.getStatus().equals(ABORTED.name())) { deleteAllJobs(requestExecution); long possibleBatchToAbort = lastCompletedBatchRequest == null? 1L : lastCompletedBatchRequest.getOrderId() + 1; Collection<Long> requestIDsToAbort = requestExecution.getBatchRequestRequestsIDs(possibleBatchToAbort); for (Long requestId : requestIDsToAbort) { if (requestId == null) continue; StrBuilder sb = new StrBuilder(); sb.append(DEFAULT_API_PATH) .append("/clusters/") .append(requestExecution.getClusterName()) .append("/requests/") .append(requestId); String body = "{\"Requests\":{\"request_status\":\"ABORTED\",\"abort_reason\":\"Request schedule status changed to " + requestExecution.getStatus() + "\"}}"; performApiRequest(sb.toString(), body, "PUT", requestExecution.getAuthenticatedUserId()); } } }

Target:
public void updateBatchSchedule(RequestExecution requestExecution) throws AmbariException { BatchRequest activeBatch = calculateActiveBatch(requestExecution); if (activeBatch == null) { LOG.warn("Ignoring RequestExecution status update since all batches has been executed"); return; } if (requestExecution.getStatus().equals(SCHEDULED.name())) { scheduleBatch(requestExecution, activeBatch.getOrderId()); } else if (requestExecution.getStatus().equals(PAUSED.name()) || requestExecution.getStatus().equals(ABORTED.name())) { LOG.info("Request execution status changed to " + requestExecution.getStatus() + " for request schedule " + requestExecution.getId() + ". Deleting related jobs."); deleteJobs(requestExecution, activeBatch.getOrderId()); Collection<Long> requestIDsToAbort = requestExecution.getBatchRequestRequestsIDs(activeBatch.getOrderId()); for (Long requestId : requestIDsToAbort) { if (requestId == null) continue; abortRequestById(requestExecution, requestId); } } }
Source:
@Override public CatboostClassificationModel parse(byte[] mdl) { try (InputStream inputStream = new ByteArrayInputStream(mdl)) { return new CatboostClassificationModel(CatBoostModel.loadModel(inputStream)); } catch (IOException | CatBoostError e) { throw new RuntimeException("Failed to parse model", e); } }

Target:
@Override public CatboostClassificationModel parse(byte[] mdl) { try (InputStream inputStream = new ByteArrayInputStream(mdl)) { return new CatboostClassificationModel(CatBoostModel.loadModel(inputStream)); } catch (IOException | CatBoostError e) { throw new RuntimeException("Failed to parse model " + e.getMessage(), e); } }
Source:
public void func_wrapping_class() { FunctionDef functionTree = functionTreesByName.get("func_wrapping_class"); assertThat(functionTree.localVariables()).hasSize(1); }

Target:
public void func_wrapping_class() { FunctionDef functionTree = functionTreesByName.get("func_wrapping_class"); assertThat(functionTree.localVariables()).extracting(Symbol::name).containsExactly("A"); }
Source:
public static ITypedElement getFileRevisionTypedElementForCommonAncestor( final String gitPath, ObjectId commit1, ObjectId commit2, Repository db) { ITypedElement ancestor = null; RevCommit commonAncestor = null; try { commonAncestor = RevUtils.getCommonAncestor(db, commit1, commit2); } catch (IOException e) { Activator.logError(NLS.bind(UIText.CompareUtils_errorCommonAncestor, commit1.getName(), commit2.getName()), e); } if (commonAncestor != null) { ITypedElement ancestorCandidate = CompareUtils .getFileRevisionTypedElement(gitPath, commonAncestor, db); if (!ITypedElement.UNKNOWN_TYPE.equals(ancestorCandidate.getType())) ancestor = ancestorCandidate; } return ancestor; }

Target:
public static ITypedElement getFileRevisionTypedElementForCommonAncestor( final String gitPath, ObjectId commit1, ObjectId commit2, Repository db) { ITypedElement ancestor = null; RevCommit commonAncestor = null; try { commonAncestor = RevUtils.getCommonAncestor(db, commit1, commit2); } catch (IOException e) { Activator.logError(NLS.bind(UIText.CompareUtils_errorCommonAncestor, commit1.getName(), commit2.getName()), e); } if (commonAncestor != null) { ITypedElement ancestorCandidate = CompareUtils .getFileRevisionTypedElement(gitPath, commonAncestor, db); if (!(ancestorCandidate instanceof EmptyTypedElement)) ancestor = ancestorCandidate; } return ancestor; }
Source:
public LinkDiscoverer getDiscoverer(MockHttpServletResponse response) { String contentType = response.getContentType(); LinkDiscoverer linkDiscovererFor = discoverers.getLinkDiscovererFor(contentType); assertThat("Did not find a LinkDiscoverer for returned media type " + contentType + "!", linkDiscovererFor, is(notNullValue())); return linkDiscovererFor; }

Target:
public LinkDiscoverer getDiscoverer(MockHttpServletResponse response) { String contentType = response.getContentType(); LinkDiscoverer linkDiscovererFor = discoverers.getLinkDiscovererFor(contentType); assertThat(linkDiscovererFor) .describedAs("Did not find a LinkDiscoverer for returned media type " + contentType + "!") .isNotNull(); return linkDiscovererFor; }
Source:
private boolean confInvocationPassed(ITestNGMethod method, ITestNGMethod currentTestMethod, IClass testClass, Object instance) { boolean result = true; Class<?> cls = testClass.getRealClass(); if(m_suiteState.isFailed()) { result = false; } else { if (classConfigurationFailed(cls)) { if (! m_continueOnFailedConfiguration) { result = !classConfigurationFailed(cls); } else { synchronized (m_classInvocationResults) { Set<Object> set = m_classInvocationResults.get(cls); while (set == null || cls.equals(Object.class)) { cls = cls.getSuperclass(); set = m_classInvocationResults.get(cls); } if (set == null) { throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } result = !set.contains(instance); } } } else if (m_continueOnFailedConfiguration && currentTestMethod != null && m_methodInvocationResults.containsKey(currentTestMethod)) { result = !m_methodInvocationResults.get(currentTestMethod).contains(getMethodInvocationToken(currentTestMethod, instance)); } else if (! m_continueOnFailedConfiguration) { synchronized(m_classInvocationResults){ for(Class<?> clazz : m_classInvocationResults.keySet()) { if (clazz.isAssignableFrom(cls)) { result = false; break; } } } } } String[] groups = method.getGroups(); if(null != groups && groups.length > 0) { for(String group : groups) { if(m_beforegroupsFailures.containsKey(group)) { result = false; break; } } } return result; }

Target:
private boolean confInvocationPassed(ITestNGMethod method, ITestNGMethod currentTestMethod, IClass testClass, Object instance) { boolean result = true; Class<?> cls = testClass.getRealClass(); if(m_suiteState.isFailed()) { result = false; } else { if (classConfigurationFailed(cls)) { if (! m_continueOnFailedConfiguration) { result = !classConfigurationFailed(cls); } else { synchronized (m_classInvocationResults) { Set<Object> set = m_classInvocationResults.get(cls); while (set == null || !cls.equals(Object.class)) { cls = cls.getSuperclass(); set = m_classInvocationResults.get(cls); } if (set == null) { throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } result = !set.contains(instance); } } } else if (m_continueOnFailedConfiguration && currentTestMethod != null && m_methodInvocationResults.containsKey(currentTestMethod)) { result = !m_methodInvocationResults.get(currentTestMethod).contains(getMethodInvocationToken(currentTestMethod, instance)); } else if (! m_continueOnFailedConfiguration) { synchronized(m_classInvocationResults){ for(Class<?> clazz : m_classInvocationResults.keySet()) { if (clazz.isAssignableFrom(cls)) { result = false; break; } } } } } String[] groups = method.getGroups(); if(null != groups && groups.length > 0) { for(String group : groups) { if(m_beforegroupsFailures.containsKey(group)) { result = false; break; } } } return result; }
Source:
public final InputStream getContent() throws IOException, IllegalStateException { if (this.objSer == null) { createBytes(this.objRef); } return new ByteArrayInputStream(this.objSer); }

Target:
public final InputStream getContent() throws IOException, IllegalStateException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
Source:
public String toString() { return "JoinAction{" + "jarId='" + jarId + '\'' + ", joinerClassName='" + joinerClassName + '\'' + ", expiryEntryInterval=" + groupExpiryInterval + '}'+super.toString(); }

Target:
public String toString() { return "JoinAction{" + "jarId='" + jarId + '\'' + ", joinerClassName='" + joinerClassName + '\'' + ", groupExpiryInterval=" + groupExpiryInterval + ", eventExpiryInterval=" + eventExpiryInterval + '}' + super.toString(); }
Source:
private IpSecManager.IpSecTunnelInterface createAndValidateVti(int resourceId, String intfName) throws Exception { IpSecTunnelInterfaceResponse dummyResponse = new IpSecTunnelInterfaceResponse(IpSecManager.Status.OK, resourceId, intfName); when(mMockIpSecService.createTunnelInterface( eq(VTI_LOCAL_ADDRESS.getHostAddress()), eq(GOOGLE_DNS_4.getHostAddress()), anyObject(), anyObject())) .thenReturn(dummyResponse); return mIpSecManager.createIpSecTunnelInterface( VTI_LOCAL_ADDRESS, GOOGLE_DNS_4, mock(Network.class)); }

Target:
private IpSecManager.IpSecTunnelInterface createAndValidateVti(int resourceId, String intfName) throws Exception { IpSecTunnelInterfaceResponse dummyResponse = new IpSecTunnelInterfaceResponse(IpSecManager.Status.OK, resourceId, intfName); when(mMockIpSecService.createTunnelInterface( eq(VTI_LOCAL_ADDRESS.getHostAddress()), eq(GOOGLE_DNS_4.getHostAddress()), anyObject(), anyObject())) .thenReturn(dummyResponse); IpSecManager.IpSecTunnelInterface tunnelIntf = mIpSecManager.createIpSecTunnelInterface( VTI_LOCAL_ADDRESS, GOOGLE_DNS_4, mock(Network.class)); assertNotNull(tunnelIntf); return tunnelIntf; }
Source:
public CtfTmfTimestamp(long timestamp) { super(timestamp, -9, 0); type = TimestampType.DAY; }

Target:
public CtfTmfTimestamp(long timestamp) { super(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0); type = TimestampType.DAY; }
Source:
private void verifyWriteSucceeds(short version, Message message) throws Exception { ObjectSerializationCache cache = new ObjectSerializationCache(); int size = message.size(cache, version); ByteBuffer buf = ByteBuffer.allocate(size * 2); ByteBufferAccessor byteBufferAccessor = new ByteBufferAccessor(buf); message.write(byteBufferAccessor, cache, version); ByteBuffer alt = buf.duplicate(); alt.flip(); StringBuilder bld = new StringBuilder(); while (alt.hasRemaining()) { bld.append(String.format(" %02x", alt.get())); } System.out.println("WATERMELON: buffer is " + bld.toString()); assertEquals("Expected the serialized size to be " + size + ", but it was " + buf.position(), size, buf.position()); }

Target:
private void verifyWriteSucceeds(short version, Message message) throws Exception { ObjectSerializationCache cache = new ObjectSerializationCache(); int size = message.size(cache, version); ByteBuffer buf = ByteBuffer.allocate(size * 2); ByteBufferAccessor byteBufferAccessor = new ByteBufferAccessor(buf); message.write(byteBufferAccessor, cache, version); ByteBuffer alt = buf.duplicate(); alt.flip(); StringBuilder bld = new StringBuilder(); while (alt.hasRemaining()) { bld.append(String.format(" %02x", alt.get())); } assertEquals("Expected the serialized size to be " + size + ", but it was " + buf.position(), size, buf.position()); }
Source:
public int hashCode() { return Objects.hash(replicaList); }

Target:
public int hashCode() { return replicaList.hashCode(); }
Source:
public DefaultCopierConfiguration(Class<? extends Copier<T>> copierClass) { super(copierClass); this.type = null; }

Target:
DefaultCopierConfiguration(Class<? extends Copier<T>> copierClass) { super(copierClass); this.type = null; }
Source:
protected int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }

Target:
protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
Source:
protected boolean validateFields() { String trimmedRegex = getRegexTextField().getText().trim(); try { if (MultipleRegexesOptionsPanel.validateRegexAndCheckForDuplicates( trimmedRegex, regexes)) { return true; } else { JOptionPane.showMessageDialog( this, TEXT_ALREADY_EXIST_INVALID_REGEX_DIALOG, TITLE_ALREADY_EXIST_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } } catch (PatternSyntaxException e) { JOptionPane.showMessageDialog( this, MessageFormat.format(TEXT_INVALID_REGEX_DIALOG, e.getLocalizedMessage()), TITLE_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } }

Target:
protected boolean validateFields() { String trimmedRegex = getRegexTextField().getText().trim(); try { if (validateRegexAndCheckForDuplicates(trimmedRegex, regexes)) { return true; } JOptionPane.showMessageDialog( this, TEXT_ALREADY_EXIST_INVALID_REGEX_DIALOG, TITLE_ALREADY_EXIST_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } catch (PatternSyntaxException e) { JOptionPane.showMessageDialog( this, MessageFormat.format(TEXT_INVALID_REGEX_DIALOG, e.getLocalizedMessage()), TITLE_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } }
Source:
public void addAttachment(SQLDatabase db,PreparedAttachment a, BasicDocumentRevision rev) throws AttachmentNotSavedException { ContentValues values = new ContentValues(); long sequence = rev.getSequence(); String filename = a.attachment.name; byte[] sha1 = a.sha1; String type = a.attachment.type; int encoding = a.attachment.encoding.ordinal(); long length = a.tempFile.length(); long revpos = CouchUtils.generationFromRevId(rev.getRevision()); values.put("sequence", sequence); values.put("filename", filename); values.put("key", sha1); values.put("type", type); values.put("encoding", encoding); values.put("length", length); values.put("encoded_length", length); values.put("revpos", revpos); db.delete("attachments", " filename = ? and sequence = ? ", new String[]{filename, String.valueOf(sequence)}); long result = db.insert("attachments", values); if (result == -1) { a.tempFile.delete(); throw new AttachmentNotSavedException("Could not insert attachment " + a + " into database with values " + values + "; not copying to attachments directory"); } File newFile = fileFromKey(sha1); if(newFile.exists()){ if(a.tempFile.exists()){ a.tempFile.delete(); } } else { try { FileUtils.moveFile(a.tempFile, newFile); } catch (FileExistsException fee) { a.tempFile.delete(); } catch (IOException e) { throw new AttachmentNotSavedException(e); } } }

Target:
public void addAttachment(SQLDatabase db,PreparedAttachment a, BasicDocumentRevision rev) throws AttachmentNotSavedException { ContentValues values = new ContentValues(); long sequence = rev.getSequence(); String filename = a.attachment.name; byte[] sha1 = a.sha1; String type = a.attachment.type; int encoding = a.attachment.encoding.ordinal(); long length = a.tempFile.length(); long revpos = CouchUtils.generationFromRevId(rev.getRevision()); values.put("sequence", sequence); values.put("filename", filename); values.put("key", sha1); values.put("type", type); values.put("encoding", encoding); values.put("length", length); values.put("encoded_length", length); values.put("revpos", revpos); db.delete("attachments", " filename = ? and sequence = ? ", new String[]{filename, String.valueOf(sequence)}); long result = db.insert("attachments", values); if (result == -1) { a.tempFile.delete(); throw new AttachmentNotSavedException("Could not insert attachment " + a + " into database with values " + values + "; not copying to attachments directory"); } File newFile = fileFromKey(sha1); try { FileUtils.moveFile(a.tempFile, newFile); } catch (FileExistsException fee) { a.tempFile.delete(); } catch (FileNotFoundException e) { if(!newFile.exists()){ throw new AttachmentNotSavedException(e); } } catch (IOException e) { if(newFile.exists()){ newFile.delete(); } if (a.tempFile.exists()){ a.tempFile.delete(); } throw new AttachmentNotSavedException(e); } }
Source:
public void applyHandshakeTimeout() { final ChannelPromise localHandshakePromise = handshakePromise; final long handshakeTimeoutMillis = this.handshakeTimeoutMillis; if (handshakeTimeoutMillis <= 0 || localHandshakePromise.isDone()) { return; } final ScheduledFuture<?> timeoutFuture = ctx.executor().schedule(new Runnable() { @Override public void run() { if (localHandshakePromise.isDone()) { return; } if (localHandshakePromise.tryFailure(HANDSHAKE_TIMED_OUT_EXCEPTION)) { ctx.flush() .fireUserEventTriggered(ServerHandshakeStateEvent.HANDSHAKE_TIMEOUT) .close(); } } }, handshakeTimeoutMillis, TimeUnit.MILLISECONDS); localHandshakePromise.addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> f) throws Exception { timeoutFuture.cancel(false); } }); }

Target:
private void applyHandshakeTimeout() { final ChannelPromise localHandshakePromise = handshakePromise; final long handshakeTimeoutMillis = this.handshakeTimeoutMillis; if (handshakeTimeoutMillis <= 0 || localHandshakePromise.isDone()) { return; } final Future<?> timeoutFuture = ctx.executor().schedule(new Runnable() { @Override public void run() { if (localHandshakePromise.tryFailure(HANDSHAKE_TIMED_OUT_EXCEPTION)) { ctx.flush() .fireUserEventTriggered(ServerHandshakeStateEvent.HANDSHAKE_TIMEOUT) .close(); } } }, handshakeTimeoutMillis, TimeUnit.MILLISECONDS); localHandshakePromise.addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> f) throws Exception { timeoutFuture.cancel(false); } }); }
Source:
private void assertNonNullWrapping(GraphQLType wrappedType) { if (wrappedType instanceof GraphQLNonNull) { throw new AssertException(String.format("A non null type cannot wrap an existing non null type '%s'", GraphQLTypeUtil.getUnwrappedTypeName(wrappedType))); } }

Target:
private void assertNonNullWrapping(GraphQLType wrappedType) { assertTrue(!GraphQLTypeUtil.isNonNull(wrappedType), String.format("A non null type cannot wrap an existing non null type '%s'", GraphQLTypeUtil.getUnwrappedTypeName(wrappedType))); }
Source:
protected void executeCommandWithConsoleSafenessWarning(final UICommand command) { VM vm = getEntity(); if (vm.getAllowConsoleReconnect() || vm.getConsoleCurentUserName() == null || Frontend.getLoggedInUser().getUserId().equals(vm.getConsoleUserId())) { command.Execute(); return; } GetRoleActionGroupsByUserIdParameters params = new GetRoleActionGroupsByUserIdParameters(vm.getConsoleUserId()); AsyncQuery query = new AsyncQuery(); query.setModel(this); query.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object result) { VdcQueryReturnValue returnValue = (VdcQueryReturnValue) result; List<ActionGroup> resultList = ((List<ActionGroup>) returnValue.getReturnValue()); if (resultList.contains(ActionGroup.RECONNECT_TO_VM)) { command.Execute(); } else { displayConsoleConnectConfirmPopup(command); } } }; Frontend.RunQuery(VdcQueryType.GetRoleActionGroupsByUserId, params, query); }

Target:
protected void executeCommandWithConsoleSafenessWarning(final UICommand command) { VM vm = getEntity(); if (vm.getAllowConsoleReconnect() || vm.getConsoleCurentUserName() == null || Frontend.getLoggedInUser().getUserId().equals(vm.getConsoleUserId())) { command.Execute(); return; } GetEntityPermissionsParameters params = new GetEntityPermissionsParameters(vm.getConsoleUserId().getValue(), ActionGroup.RECONNECT_TO_VM, vm.getId().getValue(), VdcObjectType.VM); AsyncQuery query = new AsyncQuery(); query.setModel(this); query.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object result) { NGuid returnValue = ((NGuid) ((VdcQueryReturnValue)result).getReturnValue()); if (returnValue != null) { command.Execute(); } else { displayConsoleConnectConfirmPopup(command); } } }; Frontend.RunQuery(VdcQueryType.GetEntityPermissions, params, query); }
Source:
public void startTrack() { changes = new HashMap<ByteArrayWrapper, byte[]>(); deletes = new HashMap<ByteArrayWrapper, byte[]>(); trackingChanges = true; }

Target:
public void startTrack() { changes = new HashMap<>(); deletes = new HashMap<>(); trackingChanges = true; }
Source:
public void testCreateRole() { if (roleAdminOption.isPresent()) { testRole = roleAdminOption.get().create("jclouds-test-role"); assertTrue(retry(new Predicate<RoleAdminApi>() { public boolean apply(RoleAdminApi roleApi) { return roleApi.get(testRole.getId()) != null; } }, 180 * 1000L).apply(roleAdminOption.get())); assertEquals(roleAdminOption.get().get(testRole.getId()).getName(), "jclouds-test-role"); } }

Target:
public void testCreateRole() { testRole = roleAdminOption.get().create("jclouds-test-role"); assertTrue(retry(new Predicate<RoleAdminApi>() { public boolean apply(RoleAdminApi roleApi) { return roleApi.get(testRole.getId()) != null; } }, 180 * 1000L).apply(roleAdminOption.get())); assertEquals(roleAdminOption.get().get(testRole.getId()).getName(), "jclouds-test-role"); }
Source:
public SimpleFilterProjectSemiJoinStatsRule(StatsNormalizer normalizer, FilterStatsCalculator filterStatsCalculator, FunctionManager functionManager) { super(normalizer); this.filterStatsCalculator = requireNonNull(filterStatsCalculator, "filterStatsCalculator can not be null"); this.logicalRowExpressions = new LogicalRowExpressions(requireNonNull(functionManager, "functionManager can not be null")); this.functionResolution = new StandardFunctionResolution(functionManager); }

Target:
public SimpleFilterProjectSemiJoinStatsRule(StatsNormalizer normalizer, FilterStatsCalculator filterStatsCalculator, FunctionManager functionManager) { super(normalizer); this.filterStatsCalculator = requireNonNull(filterStatsCalculator, "filterStatsCalculator can not be null"); requireNonNull(functionManager, "functionManager can not be null"); this.logicalRowExpressions = new LogicalRowExpressions(functionManager); this.functionResolution = new StandardFunctionResolution(functionManager); }
Source:
public void testGetStrippedVdsUniqueIdWithoutValidChars() { RegisterVdsParameters paramsMock = getQueryParameters(); when(paramsMock.getVdsUniqueId()).thenReturn("^%^"); String result = getQuery().getStrippedVdsUniqueId(); assertEquals("Vds id is not empty as expected", result, ""); }

Target:
public void testGetStrippedVdsUniqueIdWithoutValidChars() { String result = this.gerStrippedVdsUniqueId("^%^"); assertEquals("Vds id is not empty as expected", "", result); }
Source:
private CoreEvent addContextToEvent(CoreEvent event, Context ctx) throws MuleException { SdkInternalContext sdkInternalContext = (SdkInternalContext) ((InternalEvent) event).<SdkInternalContext>getSdkInternalContext(); if (((InternalEvent) event).getSdkInternalContext() == null) { sdkInternalContext = new SdkInternalContext(); ((InternalEvent) event).setSdkInternalContext(sdkInternalContext); } if (hasChainNested && (ctx.hasKey(POLICY_NEXT_OPERATION) || ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS))) { sdkInternalContext.setInnerChainSubscriberContextMapping(innerChainCtx -> { if (ctx.hasKey(POLICY_NEXT_OPERATION)) { innerChainCtx = innerChainCtx.put(POLICY_NEXT_OPERATION, ctx.get(POLICY_NEXT_OPERATION)); } if (ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)) { innerChainCtx = innerChainCtx.put(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS, ctx.get(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)); } return innerChainCtx; }); } sdkInternalContext.setConfiguration(resolveConfiguration(event)); final Map<String, Object> resolutionResult = getResolutionResult(event, sdkInternalContext.getConfiguration()); sdkInternalContext.setResolutionResult(resolutionResult); sdkInternalContext.setPolicyToApply(getLocation() != null ? policyManager.createOperationPolicy(this, event, () -> resolutionResult) : NO_POLICY_OPERATION); return event; }

Target:
private CoreEvent addContextToEvent(CoreEvent event, Context ctx) throws MuleException { SdkInternalContext sdkInternalContext = new SdkInternalContext(); ((InternalEvent) event).setSdkInternalContext(sdkInternalContext); if (hasNestedChain && (ctx.hasKey(POLICY_NEXT_OPERATION) || ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS))) { sdkInternalContext.setInnerChainSubscriberContextMapping(innerChainCtx -> { if (ctx.hasKey(POLICY_NEXT_OPERATION)) { innerChainCtx = innerChainCtx.put(POLICY_NEXT_OPERATION, ctx.get(POLICY_NEXT_OPERATION)); } if (ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)) { innerChainCtx = innerChainCtx.put(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS, ctx.get(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)); } return innerChainCtx; }); } sdkInternalContext.setConfiguration(resolveConfiguration(event)); final Map<String, Object> resolutionResult = getResolutionResult(event, sdkInternalContext.getConfiguration()); sdkInternalContext.setResolutionResult(resolutionResult); sdkInternalContext.setPolicyToApply(getLocation() != null ? policyManager.createOperationPolicy(this, event, () -> resolutionResult) : noPolicyOperation()); return event; }
Source:
public void testBuildSQL() { IonSqlQueryBuilder queryBuilder = new IonSqlQueryBuilder(new TypeRegistry()); List<HiveColumnHandle> columns = ImmutableList.of( new HiveColumnHandle("n_nationkey", HiveType.HIVE_INT, parseTypeSignature(StandardTypes.INTEGER), 0, REGULAR, Optional.empty()), new HiveColumnHandle("n_name", HiveType.HIVE_STRING, parseTypeSignature(StandardTypes.VARCHAR), 1, REGULAR, Optional.empty()), new HiveColumnHandle("n_regionkey", HiveType.HIVE_INT, parseTypeSignature(StandardTypes.INTEGER), 2, REGULAR, Optional.empty())); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s", queryBuilder.buildSql(columns, TupleDomain.all())); TupleDomain<HiveColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( columns.get(2), Domain.create(SortedRangeSet.copyOf(BIGINT, ImmutableList.of(Range.equal(BIGINT, 3L))), false))); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s WHERE (case s._3 when '' then null else CAST(s._3 AS int) end = 3)", queryBuilder.buildSql(columns, tupleDomain)); }

Target:
public void testBuildSQL() { IonSqlQueryBuilder queryBuilder = new IonSqlQueryBuilder(new TypeRegistry()); List<HiveColumnHandle> columns = ImmutableList.of( new HiveColumnHandle("n_nationkey", HIVE_INT, parseTypeSignature(INTEGER), 0, REGULAR, Optional.empty()), new HiveColumnHandle("n_name", HIVE_STRING, parseTypeSignature(VARCHAR), 1, REGULAR, Optional.empty()), new HiveColumnHandle("n_regionkey", HIVE_INT, parseTypeSignature(INTEGER), 2, REGULAR, Optional.empty())); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s", queryBuilder.buildSql(columns, TupleDomain.all())); TupleDomain<HiveColumnHandle> tupleDomain = withColumnDomains(ImmutableMap.of( columns.get(2), Domain.create(SortedRangeSet.copyOf(BIGINT, ImmutableList.of(Range.equal(BIGINT, 3L))), false))); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s WHERE (case s._3 when '' then null else CAST(s._3 AS INT) end = 3)", queryBuilder.buildSql(columns, tupleDomain)); }
Source:
public String getCloudService() { return getString("cloud.service", ""); }

Target:
public String getCloudService() { return getString("cloud.service"); }
Source:
public synchronized void start() throws IOException { if (rawDataChannel == null) { throw new IllegalStateException("Cannot start without message handler."); } if (bossGroup != null) { throw new IllegalStateException("Connector already started"); } if (workerGroup != null) { throw new IllegalStateException("Connector already started"); } bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(numberOfThreads); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.AUTO_READ, true).childHandler(new ChannelRegistry()); ChannelFuture channelFuture = bootstrap.bind(localAddress).syncUninterruptibly(); if (0 == localAddress.getPort()) { channelFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { InetSocketAddress listenAddress = (InetSocketAddress) future.channel().localAddress(); adjustPort(listenAddress.getPort()); } } }); try { wait(100); } catch (InterruptedException e) { } } }

Target:
public synchronized void start() throws IOException { if (rawDataChannel == null) { throw new IllegalStateException("Cannot start without message handler."); } if (bossGroup != null) { throw new IllegalStateException("Connector already started"); } if (workerGroup != null) { throw new IllegalStateException("Connector already started"); } bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(numberOfThreads); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.AUTO_READ, true).childHandler(new ChannelRegistry()); ChannelFuture channelFuture = bootstrap.bind(localAddress).syncUninterruptibly(); if (channelFuture.isSuccess() && 0 == localAddress.getPort()) { InetSocketAddress listenAddress = (InetSocketAddress) channelFuture.channel().localAddress(); localAddress = new InetSocketAddress(localAddress.getAddress(), listenAddress.getPort()); listenUri = getListenUri(localAddress); } }
Source:
ProcedureRunnerNT generateProcedureRunnerNT(AuthUser user, Connection ccxn, long clientHandle) throws InstantiationException, IllegalAccessException { long id = nextProcedureRunnerId++; VoltNTProcedure procedure = null; procedure = m_procClz.newInstance(); ProcedureRunnerNT runner = new ProcedureRunnerNT(id, user, ccxn, clientHandle, procedure, m_procedureName, m_procMethod, m_paramTypes, m_priorityExecutorService, NTProcedureService.this, m_mailbox, m_statsCollector); return runner; }

Target:
ProcedureRunnerNT generateProcedureRunnerNT(AuthUser user, Connection ccxn, long clientHandle) throws InstantiationException, IllegalAccessException { long id = nextProcedureRunnerId++; VoltNonTransactionalProcedure procedure = null; procedure = m_procClz.newInstance(); ProcedureRunnerNT runner = new ProcedureRunnerNT(id, user, ccxn, clientHandle, procedure, m_procedureName, m_procMethod, m_paramTypes, m_priorityExecutorService, NTProcedureService.this, m_mailbox, m_statsCollector); return runner; }
Source:
private boolean hasSnapshotRepoId(DeploymentRepository snapshotRepo) { return snapshotRepo.getId().equals("mulesoft-snapshots") && snapshotRepo.getUrl().equals("<LINK_0>") && !snapshotRepo.isUniqueVersion(); }

Target:
private boolean hasSnapshotRepoId(DeploymentRepository snapshotRepo) { return snapshotRepo.getId().equals("mulesoft-snapshots"); }
Source:
private static boolean isOwnDomain(String tenantDomain, String routingKey) { boolean isOwnDomain = false; if (tenantDomain != null) { if (routingKey.length() >= tenantDomain.length() + 1 && routingKey.substring(0, tenantDomain.length() + 1).equals(tenantDomain + "/")) { isOwnDomain = true; } else if (tenantDomain.equalsIgnoreCase("carbon.super")) { if (!routingKey.contains("/")) { isOwnDomain = true; } } } else { if (!routingKey.contains("/")) { isOwnDomain = true; } } return isOwnDomain; }

Target:
private static boolean isOwnDomain(String tenantDomain, String routingKey) { boolean isOwnDomain = false; if (tenantDomain != null) { if ((routingKey.length() >= tenantDomain.length() + 1) && routingKey.substring(0, tenantDomain.length() + 1).equals(tenantDomain + "/")) { isOwnDomain = true; } else if (tenantDomain.equalsIgnoreCase("carbon.super")) { if (!routingKey.contains("/")) { isOwnDomain = true; } } } else { if (!routingKey.contains("/")) { isOwnDomain = true; } } return isOwnDomain; }
Source:
static <I> AggregateEventRecord newEventRecord(I aggregateId, Event event) { checkNotNull(aggregateId); checkNotNull(event); checkArgument(event.hasContext(), "Event context must be set."); checkArgument(event.hasMessage(), "Event message must be set."); String eventIdStr = Identifier.toString(event.getId()); checkNotEmptyOrBlank(eventIdStr, "Event ID cannot be empty or blank."); EventContext context = event.context(); Timestamp timestamp = checkValid(context.getTimestamp()); Any packedId = Identifier.pack(aggregateId); AggregateEventRecordId recordId = eventRecordId(eventIdStr); return AggregateEventRecord.newBuilder() .setId(recordId) .setAggregateId(packedId) .setTimestamp(timestamp) .setEvent(event) .build(); }

Target:
static <I> AggregateEventRecord newEventRecord(I aggregateId, Event event) { checkNotNull(aggregateId); checkNotNull(event); checkArgument(event.hasContext(), "Event context must be set."); checkArgument(event.hasMessage(), "Event message must be set."); String eventIdStr = Identifier.toString(event.getId()); checkNotEmptyOrBlank(eventIdStr, "Event ID cannot be empty or blank."); EventContext context = event.context(); Timestamp timestamp = checkValid(context.getTimestamp()); Any packedId = Identifier.pack(aggregateId); AggregateEventRecordId recordId = eventRecordId(eventIdStr); AggregateEventRecord result = AggregateEventRecord .newBuilder() .setId(recordId) .setAggregateId(packedId) .setTimestamp(timestamp) .setEvent(event) .vBuild(); return result; }
Source:
public void execute(final NodeMain nodeMain, final NodeConfiguration nodeConfiguration, final Collection<NodeListener> nodeListeners) { if(isShuttingDown()) { throw new RosRuntimeException("Executing nodes after shutdown has been started."); } final NodeConfiguration nodeConfigurationCopy = NodeConfiguration.copyOf(nodeConfiguration); nodeConfigurationCopy.setDefaultNodeName(nodeMain.getDefaultNodeName()); Preconditions.checkNotNull(nodeConfigurationCopy.getNodeName(), "Node name not specified."); if (DEBUG) { log.info("Starting node: " + nodeConfigurationCopy.getNodeName()); } scheduledExecutorService.execute(new Runnable() { @Override public void run() { Collection<NodeListener> nodeListenersCopy = Lists.newArrayList(); nodeListenersCopy.add(new RegistrationListener()); nodeListenersCopy.add(nodeMain); if (nodeListeners != null) { nodeListenersCopy.addAll(nodeListeners); } Node node = nodeFactory.newNode(nodeConfigurationCopy, nodeListenersCopy); synchronized (mutex) { nodeMains.put(node, nodeMain); } } }); }

Target:
public void execute(final NodeMain nodeMain, final NodeConfiguration nodeConfiguration, final Collection<NodeListener> nodeListeners) { synchronized (mutex) { if (shutdownCountDownLatch != null) { throw new RosRuntimeException("Called execute() after calling shutdown()."); } final NodeConfiguration nodeConfigurationCopy = NodeConfiguration.copyOf(nodeConfiguration); nodeConfigurationCopy.setDefaultNodeName(nodeMain.getDefaultNodeName()); Preconditions.checkNotNull(nodeConfigurationCopy.getNodeName(), "Node name not specified."); if (DEBUG) { log.info("Starting node: " + nodeConfigurationCopy.getNodeName()); } scheduledExecutorService.execute(new Runnable() { @Override public void run() { synchronized (mutex) { if (shutdownCountDownLatch == null) { Collection<NodeListener> nodeListenersCopy = Lists.newArrayList(); nodeListenersCopy.add(new RegistrationListener()); nodeListenersCopy.add(nodeMain); if (nodeListeners != null) { nodeListenersCopy.addAll(nodeListeners); } Node node = nodeFactory.newNode(nodeConfigurationCopy, nodeListenersCopy); nodeMains.put(node, nodeMain); } } } }); } }
Source:
private void refreshRoles() throws InterruptedException { waitOnHazelcastInstanceCreation(); if ( leaderInfo.memberId() != null && leaderInfo.memberId().equals( myself ) ) { HazelcastClusterTopology.casLeaders( hazelcastInstance, leaderInfo, localDBName ); } else if ( leaderInfo.memberId() == null && localCoreServers().members().containsKey( myself ) && localCoreServers().members().size() == 1 ) { HazelcastClusterTopology.casLeaders( hazelcastInstance, leaderInfo, localDBName ); } coreRoles = HazelcastClusterTopology.getCoreRoles( hazelcastInstance, allCoreServers().members().keySet() ); }

Target:
private void refreshRoles() throws InterruptedException { waitOnHazelcastInstanceCreation(); if ( leaderInfo.memberId() != null && leaderInfo.memberId().equals( myself ) ) { HazelcastClusterTopology.casLeaders( hazelcastInstance, leaderInfo, localDBName ); } coreRoles = HazelcastClusterTopology.getCoreRoles( hazelcastInstance, allCoreServers().members().keySet() ); }
Source:
public IStatus validateEdit(final IFile[] allFiles, FileModificationValidationContext context) { final IFile[] readOnlyFiles = getReadOnlyFiles(allFiles); if (readOnlyFiles.length > 0 && context != null) { final Shell shell = getShell(context); final boolean[] ok = new boolean[] { false }; if (readOnlyFiles.length == 1) { getWorkbench().getDisplay().syncExec(() -> ok[0] = MessageDialog.openQuestion(shell, TeamUIMessages.DefaultUIFileModificationValidator_3, NLS.bind(TeamUIMessages.DefaultUIFileModificationValidator_4, new String[] { readOnlyFiles[0].getFullPath().toString() }))); } else { getWorkbench().getDisplay().syncExec(() -> ok[0] = FileListDialog.openQuestion(shell, readOnlyFiles)); } if (ok[0]) { setWritable(readOnlyFiles); }; } else if (readOnlyFiles.length > 0 && context == null) { if (isMakeWrittableWhenContextNotProvided()) { setWritable(readOnlyFiles); } } return getStatus(readOnlyFiles); }

Target:
public IStatus validateEdit(final IFile[] allFiles, FileModificationValidationContext context) { final IFile[] readOnlyFiles = getReadOnlyFiles(allFiles); if (readOnlyFiles.length > 0 && context != null) { final Shell shell = getShell(context); final boolean[] ok = new boolean[] { false }; if (readOnlyFiles.length == 1) { syncExec(() -> ok[0] = MessageDialog.openQuestion(shell, TeamUIMessages.DefaultUIFileModificationValidator_3, NLS.bind(TeamUIMessages.DefaultUIFileModificationValidator_4, new String[] { readOnlyFiles[0].getFullPath().toString() }))); } else { syncExec(() -> ok[0] = FileListDialog.openQuestion(shell, readOnlyFiles)); } if (ok[0]) { setWritable(readOnlyFiles); }; } else if (readOnlyFiles.length > 0 && context == null) { if (isMakeWrittableWhenContextNotProvided()) { setWritable(readOnlyFiles); } } return getStatus(readOnlyFiles); }
Source:
public void testTwoLibFolderExpansionAllFilesResolved() throws IOException { File lib2FolderFile = new File(workingDirFile, "lib2"); lib2FolderFile.mkdirs(); File lib2test1Jar = new File(lib2FolderFile, "test1.jar"); lib2test1Jar.createNewFile(); File lib2test2Jar = new File(lib2FolderFile, "test2.jar"); lib2test2Jar.createNewFile(); String retval = HadoopJobUtils.resolveWildCardForJarSpec(workingDirString, "./lib/*,./lib2/*", logger); Assert.assertTrue(retval.contains(workingDirFile + "/./lib/library.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/./lib/hadoop-spark-job-test-execution-x.y" + ".z-a.b.c.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/./lib2/test1.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/./lib2/test2.jar")); }

Target:
public void testTwoLibFolderExpansionAllFilesResolved() throws IOException { File lib2FolderFile = new File(workingDirFile, "lib2"); lib2FolderFile.mkdirs(); File lib2test1Jar = new File(lib2FolderFile, "test1.jar"); lib2test1Jar.createNewFile(); File lib2test2Jar = new File(lib2FolderFile, "test2.jar"); lib2test2Jar.createNewFile(); String retval = HadoopJobUtils.resolveWildCardForJarSpec(workingDirString, "lib/*,lib2/*", logger); Assert.assertTrue(retval.contains(workingDirFile + "/lib/library.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/lib/hadoop-spark-job-test-execution-x.y" + ".z-a.b.c.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/lib2/test1.jar")); Assert.assertTrue(retval.contains(workingDirFile + "/lib2/test2.jar")); }
Source:
public int update() { tableFilter.startQuery(session); tableFilter.reset(); Table table = tableFilter.getTable(); session.getUser().checkRight(table, Right.DELETE); Table resolvedTable = table; resolvedTable.fire(session, Trigger.DELETE, true); resolvedTable.lock(session, true, false); RowList rows = new RowList(session); int limitRows = -1; if (limitExpr != null) { Value v = limitExpr.getValue(session); if (v != ValueNull.INSTANCE) { limitRows = v.getInt(); } } try { setCurrentRowNumber(0); int count = 0; while (limitRows != 0 && tableFilter.next()) { setCurrentRowNumber(rows.size() + 1); if (condition == null || Boolean.TRUE.equals( condition.getBooleanValue(session))) { Row row = tableFilter.get(); boolean done = false; if (resolvedTable.fireRow()) { done = resolvedTable.fireBeforeRow(session, row, null); } if (!done) { rows.add(row); } count++; if (limitRows >= 0 && count >= limitRows) { break; } } } int rowScanCount = 0; for (rows.reset(); rows.hasNext();) { if ((++rowScanCount & 127) == 0) { checkCanceled(); } Row row = rows.next(); resolvedTable.removeRow(session, row); session.log(table, UndoLogRecord.DELETE, row); } if (resolvedTable.fireRow()) { for (rows.reset(); rows.hasNext();) { Row row = rows.next(); resolvedTable.fireAfterRow(session, row, null, false); } } resolvedTable.fire(session, Trigger.DELETE, false); return count; } finally { rows.close(); } }

Target:
public int update() { tableFilter.startQuery(session); tableFilter.reset(); Table table = tableFilter.getTable(); session.getUser().checkRight(table, Right.DELETE); table.fire(session, Trigger.DELETE, true); table.lock(session, true, false); RowList rows = new RowList(session); int limitRows = -1; if (limitExpr != null) { Value v = limitExpr.getValue(session); if (v != ValueNull.INSTANCE) { limitRows = v.getInt(); } } try { setCurrentRowNumber(0); int count = 0; while (limitRows != 0 && tableFilter.next()) { setCurrentRowNumber(rows.size() + 1); if (condition == null || Boolean.TRUE.equals( condition.getBooleanValue(session))) { Row row = tableFilter.get(); boolean done = false; if (table.fireRow()) { done = table.fireBeforeRow(session, row, null); } if (!done) { rows.add(row); } count++; if (limitRows >= 0 && count >= limitRows) { break; } } } int rowScanCount = 0; for (rows.reset(); rows.hasNext();) { if ((++rowScanCount & 127) == 0) { checkCanceled(); } Row row = rows.next(); table.removeRow(session, row); session.log(table, UndoLogRecord.DELETE, row); } if (table.fireRow()) { for (rows.reset(); rows.hasNext();) { Row row = rows.next(); table.fireAfterRow(session, row, null, false); } } table.fire(session, Trigger.DELETE, false); return count; } finally { rows.close(); } }
Source:
public Pod wait(String name, int timeoutMin, Predicate<Pod> predicate) throws InfrastructureException { String podName = getPodName(name); CompletableFuture<Pod> future = new CompletableFuture<>(); Watch watch = null; try { PodResource<Pod, DoneablePod> podResource = clientFactory.create(workspaceId).pods().inNamespace(namespace).withName(podName); watch = podResource.watch( new Watcher<Pod>() { @Override public void eventReceived(Action action, Pod pod) { if (predicate.test(pod)) { future.complete(pod); } } @Override public void onClose(KubernetesClientException cause) { future.completeExceptionally( new InfrastructureException( "Waiting for pod '" + podName + "' was interrupted")); } }); Pod actualPod = podResource.get(); if (actualPod == null) { throw new InfrastructureException("Specified pod " + podName + " doesn't exist"); } if (predicate.test(actualPod)) { return actualPod; } try { return future.get(timeoutMin, TimeUnit.MINUTES); } catch (ExecutionException e) { throw new InfrastructureException(e.getCause().getMessage(), e); } catch (TimeoutException e) { throw new InfrastructureException("Waiting for pod '" + podName + "' reached timeout"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new InfrastructureException("Waiting for pod '" + podName + "' was interrupted"); } } catch (KubernetesClientException e) { throw new KubernetesInfrastructureException(e); } finally { if (watch != null) { watch.close(); } } }

Target:
public Pod wait(String name, int timeoutMin, Predicate<Pod> predicate) throws InfrastructureException { String podName = getPodName(name); CompletableFuture<Pod> future = new CompletableFuture<>(); Watch watch = null; try { PodResource<Pod, DoneablePod> podResource = clientFactory.create(workspaceId).pods().inNamespace(namespace).withName(podName); watch = podResource.watch( new Watcher<Pod>() { @Override public void eventReceived(Action action, Pod pod) { if (predicate.test(pod)) { future.complete(pod); } } @Override public void onClose(KubernetesClientException cause) { future.completeExceptionally( new InfrastructureException( "Waiting for pod '" + podName + "' was interrupted")); } }); Pod actualPod = podResource.get(); if (actualPod == null) { if (name.equals(podName)) { throw new InfrastructureException("Specified pod " + podName + " doesn't exist"); } else { throw new InfrastructureException("No pod in deployment " + name + " found."); } } if (predicate.test(actualPod)) { return actualPod; } try { return future.get(timeoutMin, TimeUnit.MINUTES); } catch (ExecutionException e) { throw new InfrastructureException(e.getCause().getMessage(), e); } catch (TimeoutException e) { throw new InfrastructureException("Waiting for pod '" + podName + "' reached timeout"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new InfrastructureException("Waiting for pod '" + podName + "' was interrupted"); } } catch (KubernetesClientException e) { throw new KubernetesInfrastructureException(e); } finally { if (watch != null) { watch.close(); } } }
Source:
public static int nvl(Integer value, int valueWhenNull) { if (value != null) { return value.intValue(); } else { return valueWhenNull; } }

Target:
public static int nvl(Integer value, int valueWhenNull) { if (value != null) { return value.intValue(); } return valueWhenNull; }