auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void updateStream() throws IOException { if (mBlockInStream != null && mBlockInStream.remaining() > 0) { return; } if (mBlockInStream != null && mBlockInStream.remaining() == 0) { closeBlockInStream(mBlockInStream); } long blockId = mStatus.getBlockIds().get(Math.toIntExact(mPosition / mBlockSize)); <START> BlockInfo blockInfo = mStatus.getBlockInfo(blockId); <END> if (blockInfo == null) { throw new IOException("Block " + blockId + " does not exist"); } mBlockInStream = mBlockStore.getInStream(blockInfo, mOptions, mFailedWorkers); long offset = mPosition % mBlockSize; mBlockInStream.seek(offset); }</code><technical_language>@calvinjia is this intentional contact master re-using existing info? If yes, a flag guard this</technical_language>

Target:
private void updateStream() throws IOException { if (mBlockInStream != null && mBlockInStream.remaining() > 0) { return; } if (mBlockInStream != null && mBlockInStream.remaining() == 0) { closeBlockInStream(mBlockInStream); } long blockId = mStatus.getBlockIds().get(Math.toIntExact(mPosition / mBlockSize)); BlockInfo blockInfo = mStatus.getBlockInfo(blockId); if (blockInfo == null) { throw new IOException("No BlockInfo for block(id=" + blockId + ") of file" + "(id=" + mStatus.getFileId() + ", path=" + mStatus.getPath() + ")"); } boolean isBlockInfoOutdated = true; for (BlockLocation location : blockInfo.getLocations()) { if (!mFailedWorkers.containsKey(location.getWorkerAddress())) { isBlockInfoOutdated = false; break; } } if (isBlockInfoOutdated) { mBlockInStream = mBlockStore.getInStream(blockId, mOptions, mFailedWorkers); } else { mBlockInStream = mBlockStore.getInStream(blockInfo, mOptions, mFailedWorkers); } long offset = mPosition % mBlockSize; mBlockInStream.seek(offset); }
Source:
<code>public void bindServiceShouldCallOnServiceConnectedWithDefaultValues() { TestService service = new TestService(); ComponentName expectedComponentName = new ComponentName("", ""); NullBinder expectedBinder = new NullBinder(); Shadows.shadowOf(RuntimeEnvironment.application).setComponentNameAndServiceForBindService(expectedComponentName, expectedBinder); RuntimeEnvironment.application.bindService(new Intent(""), service, Context.BIND_AUTO_CREATE); <START> assertEquals(expectedComponentName, service.name); <END> assertEquals(expectedBinder, service.service); assertNull(service.nameUnbound); RuntimeEnvironment.application.unbindService(service); assertEquals(expectedComponentName, service.nameUnbound); }</code><technical_language>change assertions assertThat? Thanks</technical_language>

Target:
public void bindServiceShouldCallOnServiceConnectedWithDefaultValues() { TestService service = new TestService(); ComponentName expectedComponentName = new ComponentName("", ""); NullBinder expectedBinder = new NullBinder(); Shadows.shadowOf(RuntimeEnvironment.application).setComponentNameAndServiceForBindService(expectedComponentName, expectedBinder); RuntimeEnvironment.application.bindService(new Intent(""), service, Context.BIND_AUTO_CREATE); assertThat(service.name).isEqualTo(expectedComponentName); assertThat(service.service).isEqualTo(expectedBinder); assertThat(service.nameUnbound).isNull(); RuntimeEnvironment.application.unbindService(service); assertThat(service.nameUnbound).isEqualTo(expectedComponentName); }
Source:
<code>public int size() { FeatureReader<SimpleFeatureType,SimpleFeature> fr = null; if (featureCache != null) { return featureCache.size(); } try { int size = featureSource.getCount(query); if(size >= 0) { return size; } else { List<SimpleFeature> tempFeatureCache = new ArrayList<SimpleFeature>(); fr = featureSource.getReader(query); int count = 0; while(fr.hasNext()) { SimpleFeature feature = fr.next(); if (tempFeatureCache.size() < FEATURE_CACHE_LIMIT) tempFeatureCache.add(feature); count++; } if (count <= FEATURE_CACHE_LIMIT) { featureCache = tempFeatureCache; } <START> else { <END> tempFeatureCache.clear(); } return count; } } catch (IOException e) { throw new RuntimeException(e); } finally { if(fr != null) { try { fr.close(); } catch (IOException e) { throw new RuntimeException(e); } } } }</code><technical_language>follow coding conventions</technical_language>

Target:
public int size() { FeatureReader<SimpleFeatureType,SimpleFeature> fr = null; if (featureCache != null) { return featureCache.size(); } try { int size = featureSource.getCount(query); if(size >= 0) { return size; } else if (FEATURE_CACHE_LIMIT <= 0) { AttributeDescriptor chosen = getSmallAttributeInSchema(); Query q = new Query(query); if(chosen != null) { q.setPropertyNames(Collections.singletonList(chosen.getLocalName())); } fr = featureSource.getReader(q); int count = 0; while(fr.hasNext()) { fr.next(); count++; } return count; } else { List<SimpleFeature> tempFeatureCache = new ArrayList<SimpleFeature>(); fr = featureSource.getReader(query); int count = 0; while(fr.hasNext()) { SimpleFeature feature = fr.next(); if (tempFeatureCache.size() < FEATURE_CACHE_LIMIT) tempFeatureCache.add(feature); count++; } if (count <= FEATURE_CACHE_LIMIT) { featureCache = tempFeatureCache; } else { tempFeatureCache.clear(); } return count; } } catch (IOException e) { throw new RuntimeException(e); } finally { if(fr != null) { try { fr.close(); } catch (IOException e) { throw new RuntimeException(e); } } } }
Source:
<code>private void fireRefreshAsync(final IConnectionWrapper wrapper) { Display.getDefault().asyncExec(new Runnable() { public void run() { refreshViewer(wrapper); <START> if (viewer instanceof TreeViewer) { <END> TreeViewer treeViewer = (TreeViewer) viewer; treeViewer.expandToLevel(wrapper, 1); } } }); }</code><technical_language>check if viewer is disposed some point</technical_language>

Target:
private void fireRefreshAsync(final IConnectionWrapper wrapper) { Display.getDefault().asyncExec(new Runnable() { public void run() { refreshViewer(wrapper); if (viewer instanceof TreeViewer && !((TreeViewer) viewer).getTree().isDisposed()) { TreeViewer treeViewer = (TreeViewer) viewer; treeViewer.expandToLevel(wrapper, 1); } } }); }
Source:
<code>public void networkExists() throws Exception { <START> assertEquals(ValidationResult.VALID.getMessage(), validator.networkExists().getMessage()); <END> }</code><technical_language>assertEquals compare objects, compare ValidationResult objects: assertEquals(ValidationResult.VALID, validator.networkExists()); in file</technical_language>

Target:
public void networkExists() throws Exception { assertEquals(ValidationResult.VALID, validator.networkExists()); }
Source:
<code>@Override public List<Type> getStateType(AggContext info) { <START> return Collections.singletonList(HashMap.class); <END> }</code><technical_language>Map</technical_language>

Target:
@Override public List<Type> getStateType(AggContext info) { return Collections.singletonList(Map.class); }
Source:
<code>private static List<ITmfStateInterval> queryAttributeRange(ITmfStateSystem ss, long t1, long t2, int baseQuark, String featureString) throws AttributeNotFoundException, TimeRangeException { Pair<Long, Long> timeRange = new Pair<Long, Long>(t1, t2); int mipmapQuark = -1; List<ITmfStateInterval> intervals = new ArrayList<ITmfStateInterval>(); try { try { mipmapQuark = ss.getQuarkRelative(baseQuark, featureString); } catch (AttributeNotFoundException e) { if (t1 == t2) { ITmfStateInterval interval = ss.querySingleState(t1, baseQuark); if (!interval.getStateValue().isNull()) { intervals.add(interval); } } else { for (ITmfStateInterval interval : ss.queryHistoryRange(baseQuark, t1, t2)) { if (!interval.getStateValue().isNull()) { intervals.add(interval); } } } return intervals; } ITmfStateInterval maxLevelInterval = ss.querySingleState(timeRange.getSecond(), mipmapQuark); int levelMax = maxLevelInterval.getStateValue().unboxInt(); queryMipmapAttributeRange(ss, 0, levelMax, baseQuark, mipmapQuark, timeRange, intervals); return intervals; } catch (StateValueTypeException e) { Activator.logError("State system advertises mipmaps," + <START> " but doesn't actually have them."); END> } catch (StateSystemDisposedException e) { } return intervals; }</code><technical_language>rethrow exception stack? In this case, exception occurs if queried attribute a sub-attribute matching mipmap feature name ("max","min","avg") sub-attribute built mipmap state provider</technical_language>

Target:
private static List<ITmfStateInterval> queryAttributeRange(ITmfStateSystem ss, long t1, long t2, int baseQuark, String featureString) throws AttributeNotFoundException, TimeRangeException, StateValueTypeException { Pair<Long, Long> timeRange = new Pair<Long, Long>(t1, t2); int mipmapQuark = -1; List<ITmfStateInterval> intervals = new ArrayList<ITmfStateInterval>(); try { try { mipmapQuark = ss.getQuarkRelative(baseQuark, featureString); } catch (AttributeNotFoundException e) { if (t1 == t2) { ITmfStateInterval interval = ss.querySingleState(t1, baseQuark); if (!interval.getStateValue().isNull()) { intervals.add(interval); } } else { for (ITmfStateInterval interval : ss.queryHistoryRange(baseQuark, t1, t2)) { if (!interval.getStateValue().isNull()) { intervals.add(interval); } } } return intervals; } ITmfStateInterval maxLevelInterval = ss.querySingleState(timeRange.getSecond(), mipmapQuark); int levelMax = maxLevelInterval.getStateValue().unboxInt(); queryMipmapAttributeRange(ss, 0, levelMax, baseQuark, mipmapQuark, timeRange, intervals); return intervals; } catch (StateValueTypeException e) { throw new StateValueTypeException("State system advertises mipmaps," + " but doesn't actually have them.", e); } catch (StateSystemDisposedException e) { } return intervals; }
Source:
<code>private void invokeTestInstancePreDestroyCallback(JupiterEngineExecutionContext context) { <START> if (isPerClassLifecycle(context)) { <END> ExtensionContext extensionContext = context.getExtensionContext(); ThrowableCollector throwableCollector = context.getThrowableCollector(); Object testInstance = extensionContext.getTestInstance().orElse(null); context.getExtensionRegistry().stream(TestInstancePreDestroyCallback.class).forEach( extension -> throwableCollector.execute( () -> extension.preDestroyTestInstance(testInstance, extensionContext))); } }</code><technical_language>consider moving this if statement call method instead of</technical_language>

Target:
private void invokeTestInstancePreDestroyCallback(JupiterEngineExecutionContext context) { ExtensionContext extensionContext = context.getExtensionContext(); ThrowableCollector throwableCollector = context.getThrowableCollector(); context.getExtensionRegistry().stream(TestInstancePreDestroyCallback.class).forEach( extension -> throwableCollector.execute(() -> extension.preDestroyTestInstance(extensionContext))); }
Source:
<code>protected String getMimeType() throws IOException { <START> return Files.probeContentType(path); <END> }</code><technical_language><LINK_0> give application chance return custom MIME type. I do here</technical_language>

Target:
protected String getMimeType() throws IOException { String mimeType = null; if (Application.exists()) { mimeType = Application.get().getMimeType(path.getFileName().toString()); } if (mimeType == null) { mimeType = Files.probeContentType(path); } return mimeType; }
Source:
<code>public List<Comment> getAllComments(String uuid, PaginationRequest request) throws CommentManagementException, SQLException, DBConnectionException { if (log.isDebugEnabled()) { log.debug("Getting comment of the application release (" + uuid + ") from the database"); } Connection conn; PreparedStatement stmt = null; ResultSet rs = null; List<Comment> comments = new ArrayList<>(); String sql = ""; try { conn = this.getDBConnection(); sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT, AP_APP_RELEASE WHERE AP_APP_COMMENT.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID " + "AND AP_APP_RELEASE.UUID =? LIMIT ? OFFSET ?;"; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); stmt.setInt(2, request.getLimit()); stmt.setInt(3, request.getOffSet()); rs = stmt.executeQuery(); while (rs.next()) { Comment comment = new Comment(); comment.setId(rs.getInt("ID")); <START> comment.setTenantId(rs.getInt("TENANT_ID")); <END> comment.setComment(rs.getString("COMMENT_TEXT")); comment.setCreatedAt(rs.getTimestamp("CREATED_AT")); comment.setCreatedBy(rs.getString("CREATED_BY")); comment.setModifiedAt(rs.getTimestamp("MODEFIED_AT")); comment.setModifiedBy(rs.getString("MODEFIED_BY")); comment.setParent(rs.getInt("PARENT_ID")); comments.add(comment); } } finally { Util.cleanupResources(stmt, rs); } return comments; }</code><technical_language>@NishadiPrasangini string values multiple times file, define a constant</technical_language>

Target:
public List<Comment> getAllComments(String uuid, PaginationRequest request) throws CommentManagementException, SQLException, DBConnectionException { if (log.isDebugEnabled()) { log.debug("Getting comment of the application release (" + uuid + ") from the database"); } Connection conn; PreparedStatement statement = null; ResultSet rs = null; List<Comment> comments = new ArrayList<>(); try { conn = this.getDBConnection(); sql = "SELECT COMMENT_TEXT FROM AP_APP_COMMENT, AP_APP_RELEASE WHERE AP_APP_COMMENT.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID " + "AND AP_APP_RELEASE.UUID =? LIMIT ? OFFSET ?;"; statement = conn.prepareStatement(sql); statement.setString(1, uuid); statement.setInt(2, request.getLimit()); statement.setInt(3, request.getOffSet()); rs = statement.executeQuery(); while (rs.next()) { Comment comment = new Comment(); comment.setId(rs.getInt("ID")); comment.setTenantId(rs.getInt("TENANT_ID")); comment.setComment(rs.getString("COMMENT_TEXT")); comment.setCreatedAt(rs.getTimestamp("CREATED_AT")); comment.setCreatedBy(rs.getString("CREATED_BY")); comment.setModifiedAt(rs.getTimestamp("MODEFIED_AT")); comment.setModifiedBy(rs.getString("MODEFIED_BY")); comment.setParent(rs.getInt("PARENT_ID")); comments.add(comment); } } finally { Util.cleanupResources(statement, rs); } return comments; }
Source:
<code>private void bindTriggerIfPresent(Class<? extends Annotation> annotationClass, AccessibleObject fieldOrMethod) { if (fieldOrMethod instanceof Method && fieldOrMethod.isAnnotationPresent(annotationClass)) { Annotation trigger = fieldOrMethod.getAnnotation(annotationClass); String value; try { value = (String) annotationClass.getMethod("value").invoke(trigger); } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { value = ""; } Method method = (Method) fieldOrMethod; LifeCycleHook callback = (entity, scope, changes) -> { try { if (changes.isPresent() && method.getParameterCount() == 2 && method.getParameterTypes()[0].isInstance(scope) && method.getParameterTypes()[1].isInstance(changes.get())) { method.invoke(entity, scope, changes.get()); } else if (method.getParameterCount() == 1 && method.getParameterTypes()[0].isInstance(scope)) { method.invoke(entity, scope); } else { method.invoke(entity); } } catch (ReflectiveOperationException e) { Throwables.propagateIfPossible(e.getCause()); throw new IllegalArgumentException(e); } }; <START> fieldsToTriggers.put(Pair.of(annotationClass, value), callback); <END> } }</code><technical_language>call bindTrigger here</technical_language>

Target:
private void bindTriggerIfPresent(Class<? extends Annotation> annotationClass, AccessibleObject fieldOrMethod) { if (fieldOrMethod instanceof Method && fieldOrMethod.isAnnotationPresent(annotationClass)) { Annotation trigger = fieldOrMethod.getAnnotation(annotationClass); String value; try { value = (String) annotationClass.getMethod("value").invoke(trigger); } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { value = ""; } Method method = (Method) fieldOrMethod; int paramCount = method.getParameterCount(); Class<?> paramTypes = method.getParameterTypes(); LifeCycleHook callback = (entity, scope, changes) -> { try { if (changes.isPresent() && paramCount == 2 && paramTypes[0].isInstance(scope) && paramTypes[1].isInstance(changes.get())) { method.invoke(entity, scope, changes.get()); } else if (paramCount == 1 && paramTypes[0].isInstance(scope)) { method.invoke(entity, scope); } else { method.invoke(entity); } } catch (ReflectiveOperationException e) { Throwables.propagateIfPossible(e.getCause()); throw new IllegalArgumentException(e); } }; bindTrigger(annotationClass, value, callback); } }
Source:
<code>protected void execute(final RebaseOperation rebase) throws ExecutionException { final Repository repository = rebase.getRepository(); if (repository == null) return; final RebaseCommand.Operation operation = rebase.getOperation(); JobUtil.scheduleUserJob(rebase, jobname, JobFamilies.REBASE, new JobChangeAdapter() { @Override public void aboutToRun(IJobChangeEvent event) { if (operation == Operation.BEGIN && !repository.getRepositoryState().equals( RepositoryState.SAFE)) { throw new IllegalStateException( "Can't start rebase if repository state isn't SAFE"); } super.aboutToRun(event); } @Override public void done(IJobChangeEvent cevent) { IStatus result = cevent.getJob().getResult(); if (operation == Operation.BEGIN && result.getSeverity() == IStatus.ERROR) { handleBeginError(repository, result); } else if (result.getSeverity() == IStatus.CANCEL) Display.getDefault().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getShell(); MessageDialog .openInformation( shell, UIText.AbstractRebaseCommand_DialogTitle, dialogMessage); } }); else if (result.isOK()) RebaseResultDialog.show(rebase.getResult(), repository); } }); <START> return; <END> }</code><technical_language>this return statement removed</technical_language>

Target:
protected void execute(final RebaseOperation rebase) throws ExecutionException { final Repository repository = rebase.getRepository(); if (repository == null) return; final RebaseCommand.Operation operation = rebase.getOperation(); JobUtil.scheduleUserJob(rebase, jobname, JobFamilies.REBASE, new JobChangeAdapter() { @Override public void aboutToRun(IJobChangeEvent event) { if (operation == Operation.BEGIN && !repository.getRepositoryState().equals( RepositoryState.SAFE)) { throw new IllegalStateException( "Can't start rebase if repository state isn't SAFE"); } super.aboutToRun(event); } @Override public void done(IJobChangeEvent cevent) { IStatus result = cevent.getJob().getResult(); if (operation == Operation.BEGIN && result.getSeverity() == IStatus.ERROR) { handleBeginError(repository, result); } else if (result.getSeverity() == IStatus.CANCEL) Display.getDefault().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getShell(); MessageDialog .openInformation( shell, UIText.AbstractRebaseCommand_DialogTitle, dialogMessage); } }); else if (result.isOK()) RebaseResultDialog.show(rebase.getResult(), repository); } }); }
Source:
<code><START> public void shouldHandleNullValueFromExpectObjectFormatInSchemaVisitor() throws JsonProcessingException { <END> final MonetaryAmountSerializer monetaryAmountSerializer = new MonetaryAmountSerializer(FieldNames.defaults(), new AmountWriter<BigDecimal>() { @Override public Class<BigDecimal> getType() { return BigDecimal.class; } @Override public BigDecimal write(final MonetaryAmount amount) { return amount.getNumber().numberValueExact(BigDecimal.class).stripTrailingZeros(); } }, new NoopMonetaryAmountFormatFactory()); final JsonFormatVisitorWrapper jsonFormatVisitorWrapperMock = mock(JsonFormatVisitorWrapper.class); try { monetaryAmountSerializer.acceptJsonFormatVisitor(jsonFormatVisitorWrapperMock, SimpleType.constructUnsafe(javax.money.MonetaryAmount.class)); } catch (NullPointerException ex) { fail(); } }</code><technical_language>prefer a test of mbknor-jackson-jsonschema prove works</technical_language>

Target:
public void shouldHandleNullValueFromExpectObjectFormatInSchemaVisitor() throws Exception { final MonetaryAmountSerializer monetaryAmountSerializer = new MonetaryAmountSerializer(FieldNames.defaults(), new AmountWriter<BigDecimal>() { @Override public Class<BigDecimal> getType() { return BigDecimal.class; } @Override public BigDecimal write(final MonetaryAmount amount) { return amount.getNumber().numberValueExact(BigDecimal.class).stripTrailingZeros(); } }, new NoopMonetaryAmountFormatFactory()); final JsonFormatVisitorWrapper jsonFormatVisitorWrapperMock = mock(JsonFormatVisitorWrapper.class); monetaryAmountSerializer.acceptJsonFormatVisitor(jsonFormatVisitorWrapperMock, SimpleType.constructUnsafe(javax.money.MonetaryAmount.class)); }
Source:
<code>public RenderTank() { parts.add(new RenderPartElement<>((tile, part) -> { part.sizeY = ((double)tile.tank.getFluidAmount() / tile.tank.getCapacity()) * 16.0 / 16.0; if(part.sizeY != 0) { part.sizeX = part.sizeZ = 10.0 / 16.0; } else { part.sizeX = part.sizeZ = 0; } part.center.positiond(0.5, part.sizeY / 2, 0.5); if(tile.tank.getFluidType() == null) { return; } part.topTexture = part.bottomTexture = part.northTexture = part.southTexture = part.eastTexture = part.westTexture = tile.tank.getFluidType().getStill(); part.shouldSideBeRendered = side -> { if(side.getAxis() == EnumFacing.Axis.Y) { if(Minecraft.getMinecraft().theWorld.getBlockState(tile.getPos().offset(side)).getBlock() instanceof BlockTank) { TileTank tileSide = (TileTank) Minecraft.getMinecraft().theWorld.getTileEntity(tile.getPos().offset(side)); return tileSide.tank.isEmpty(); } return true; } return true; <START> }; <END> })); }</code><technical_language>This replaced a specialised fluid renderer, this squishes side texture in odd ways. need render buffer for fluid rendering, get culling problem</technical_language>

Target:
public RenderTank() { parts.add(new RenderPartElement<>((tile, part) -> { part.sizeY = ((double)tile.tank.getFluidAmount() / tile.tank.getCapacity()) * 16.0 / 16.0; if(part.sizeY != 0) { part.sizeX = part.sizeZ = 12.0 / 16.0 * 0.99; } else { part.sizeX = part.sizeZ = 0; } part.center.positiond(0.5, part.sizeY / 2, 0.5); if(tile.tank.getFluidType() == null) { return; } part.topTexture = part.bottomTexture = part.northTexture = part.southTexture = part.eastTexture = part.westTexture = tile.tank.getFluidType().getStill(); part.shouldSideBeRendered = side -> { if(side.getAxis() == EnumFacing.Axis.Y) { if(Minecraft.getMinecraft().theWorld.getBlockState(tile.getPos().offset(side)).getBlock() instanceof BlockTank) { TileTank tileSide = (TileTank) Minecraft.getMinecraft().theWorld.getTileEntity(tile.getPos().offset(side)); return tileSide.tank.isEmpty(); } return true; } return true; }; })); }
Source:
<code>public static File[] getHadoopDependencyFilesToLoad( List<String> hadoopDependencyCoordinates, ExtensionsConfig extensionsConfig ) { final File[] hadoopDependenciesToLoad = new File[hadoopDependencyCoordinates.size()]; final File rootHadoopDependenciesDir = new File(extensionsConfig.getHadoopDependenciesDir()); int i = 0; for (final String coordinate : hadoopDependencyCoordinates) { final DefaultArtifact artifact = new DefaultArtifact(coordinate); final File hadoopDependencyDir = new File(rootHadoopDependenciesDir, artifact.getArtifactId()); final File versionDir = new File(hadoopDependencyDir, artifact.getVersion()); <START> if (!hadoopDependencyDir.exists() || !versionDir.exists()) { <END> throw new RuntimeException( String.format("Hadoop dependency [%s] didn't exist!?", versionDir.getAbsolutePath()) ); } hadoopDependenciesToLoad[i++] = versionDir; } return hadoopDependenciesToLoad; }</code><technical_language>Suggest checking if directories</technical_language>

Target:
public static File[] getHadoopDependencyFilesToLoad( List<String> hadoopDependencyCoordinates, ExtensionsConfig extensionsConfig ) { final File rootHadoopDependenciesDir = new File(extensionsConfig.getHadoopDependenciesDir()); if (rootHadoopDependenciesDir.exists() && !rootHadoopDependenciesDir.isDirectory()) { throw new ISE("Root Hadoop dependencies directory [%s] is not a directory!?", rootHadoopDependenciesDir); } final File[] hadoopDependenciesToLoad = new File[hadoopDependencyCoordinates.size()]; int i = 0; for (final String coordinate : hadoopDependencyCoordinates) { final DefaultArtifact artifact = new DefaultArtifact(coordinate); final File hadoopDependencyDir = new File(rootHadoopDependenciesDir, artifact.getArtifactId()); final File versionDir = new File(hadoopDependencyDir, artifact.getVersion()); if (!hadoopDependencyDir.isDirectory() || !versionDir.isDirectory()) { throw new ISE( String.format("Hadoop dependency [%s] didn't exist!?", versionDir.getAbsolutePath()) ); } hadoopDependenciesToLoad[i++] = versionDir; } return hadoopDependenciesToLoad; }
Source:
<code>protected ParentTopTeamColumn() { <START> } <END></code><technical_language>this constructor private - this class is intended instantiated</technical_language>

Target:
private ParentTopTeamColumn() { }
Source:
<code>public void deleteUser(SessionId sessionId, ACOrgUnitId userId) throws ESException { checkForNulls(sessionId, userId); final ESAuthorizationService authorizationService = getAccessControl().getAuthorizationService(); authorizationService.checkProjectAdminAccessForOrgUnit( sessionId.toAPI(), userId.toAPI()); authorizationService.checkProjectAdminAccess( sessionId.toAPI(), null, ESProjectAdminPrivileges.DeleteOrgUnit); ACUser userToDelete = null; for (final Iterator<ACUser> iter = getUsers().iterator(); iter.hasNext();) { final ACUser user = iter.next(); if (user.getCreatedBy() != null && user.getCreatedBy().equals(userId.getId())) { user.setCreatedBy(null); <START> save(); <END> } if (user.getId().equals(userId)) { userToDelete = user; } } for (final ACGroup group : getGroups()) { if (group.getCreatedBy() != null && group.getCreatedBy().equals(userId.getId())) { group.setCreatedBy(null); save(); } } if (userToDelete != null) { final List<ACGroup> groups = getGroups(sessionId, userId); for (final ACGroup acGroup : groups) { removeMember(sessionId, acGroup.getId(), userId); } getAccessControl().getOrgUnitProviderService().removeUser(userToDelete.toAPI()); EcoreUtil.delete(userToDelete); save(); } }</code><technical_language>do save loop? sense save loop</technical_language>

Target:
public void deleteUser(SessionId sessionId, ACOrgUnitId userId) throws ESException { checkForNulls(sessionId, userId); final ESAuthorizationService authorizationService = getAccessControl().getAuthorizationService(); authorizationService.checkProjectAdminAccessForOrgUnit( sessionId.toAPI(), userId.toAPI()); authorizationService.checkProjectAdminAccess( sessionId.toAPI(), null, ESProjectAdminPrivileges.DeleteOrgUnit); ACUser userToDelete = null; for (final Iterator<ACUser> iter = getUsers().iterator(); iter.hasNext();) { final ACUser user = iter.next(); if (user.getCreatedBy() != null && user.getCreatedBy().equals(userId.getId())) { user.setCreatedBy(null); } if (user.getId().equals(userId)) { userToDelete = user; } } for (final ACGroup group : getGroups()) { if (group.getCreatedBy() != null && group.getCreatedBy().equals(userId.getId())) { group.setCreatedBy(null); } } if (userToDelete != null) { final List<ACGroup> groups = getGroups(sessionId, userId); for (final ACGroup acGroup : groups) { removeMember(sessionId, acGroup.getId(), userId); } getAccessControl().getOrgUnitProviderService().removeUser(userToDelete.toAPI()); EcoreUtil.delete(userToDelete); save(); } }
Source:
<code>public Builder withProjectId(String projectId) { <START> return withProjectId(ValueProvider.StaticValueProvider.of(projectId)); <END> }</code><technical_language>I import StaticValueProvider</technical_language>

Target:
public Builder withProjectId(String projectId) { return withProjectId(StaticValueProvider.of(projectId)); }
Source:
<code>private static PRINTER_INFO_2[] getPrinterInfo2(int flags) { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference(); <START> Winspool.INSTANCE.EnumPrinters(flags, null, 2, null, 0, pcbNeeded, pcReturned); <END> if (pcbNeeded.getValue() <= 0) { return new PRINTER_INFO_2[0]; } PRINTER_INFO_2 pPrinterEnum = new PRINTER_INFO_2(pcbNeeded.getValue()); if (!Winspool.INSTANCE.EnumPrinters(flags, null, 2, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } pPrinterEnum.read(); return (PRINTER_INFO_2[]) pPrinterEnum.toArray(pcReturned.getValue()); }</code><technical_language>Failures need raise Win32Exception, check explicitly for return code is tells call function actual buffer</technical_language>

Target:
private static PRINTER_INFO_2[] getPrinterInfo2(int flags) { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference(); Winspool.INSTANCE.EnumPrinters(flags, null, 2, null, 0, pcbNeeded, pcReturned); if (pcbNeeded.getValue() <= 0) return new PRINTER_INFO_2[0]; PRINTER_INFO_2 pPrinterEnum = new PRINTER_INFO_2(pcbNeeded.getValue()); if (!Winspool.INSTANCE.EnumPrinters(flags, null, 2, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); pPrinterEnum.read(); return (PRINTER_INFO_2[]) pPrinterEnum.toArray(pcReturned.getValue()); }
Source:
<code>private PersistenceService createServiceInstance() { String storage = this.configurationService.getConfiguration().getStorage(); switch (storage) { case "h2": this.sqlProvider = new H2PersistenceProvider(this.configurationService); setTimerForDBCleanUpTask(); return new SqlPersistenceServiceImpl(this.sqlProvider, this.configurationService); case "redis": return new RedisPersistenceService(this.configurationService.getConfiguration()); case "jdbc": this.sqlProvider = new JDBCPersistenceProvider(this.configurationService); setTimerForDBCleanUpTask(); return new SqlPersistenceServiceImpl(this.sqlProvider, this.configurationService); case "gluu_server_configuration": setTimerForDBCleanUpTask(); return new GluuPersistenceService(this.configurationService.getConfiguration()); case "ldap": setTimerForDBCleanUpTask(); return new GluuPersistenceService(this.configurationService.getConfiguration(), storage); case "couchbase": <START> setTimerForDBCleanUpTask(); <END> return new GluuPersistenceService(this.configurationService.getConfiguration(), storage); } throw new RuntimeException("Failed to create persistence provider. Unrecognized storage specified: " + storage + ", full configuration: " + this.configurationService.get()); }</code><technical_language>is wrong, need timer for couchbase. Add expired entity @Expiration private Integer ttl; // in seconds set expiration in seconds couchbase clean automatically</technical_language>

Target:
private PersistenceService createServiceInstance() { String storage = this.configurationService.getConfiguration().getStorage(); switch (storage) { case "h2": this.sqlProvider = new H2PersistenceProvider(this.configurationService); setTimerForDBCleanUpTask(); return new SqlPersistenceServiceImpl(this.sqlProvider, this.configurationService); case "redis": return new RedisPersistenceService(this.configurationService.getConfiguration()); case "jdbc": this.sqlProvider = new JDBCPersistenceProvider(this.configurationService); setTimerForDBCleanUpTask(); return new SqlPersistenceServiceImpl(this.sqlProvider, this.configurationService); case "gluu_server_configuration": setTimerForDBCleanUpTask(); return new GluuPersistenceService(this.configurationService.getConfiguration()); case "ldap": setTimerForDBCleanUpTask(); return new GluuPersistenceService(this.configurationService.getConfiguration(), storage); case "couchbase": return new GluuPersistenceService(this.configurationService.getConfiguration(), storage); } throw new RuntimeException("Failed to create persistence provider. Unrecognized storage specified: " + storage + ", full configuration: " + this.configurationService.get()); }
Source:
<code><START> private List<ITheme> getCSSThemes(boolean highContrastMode) { <END> List<ITheme> themes = new ArrayList<ITheme>(); for (ITheme theme : engine.getThemes()) { if (!highContrastMode && theme.getId().equals(E4Application.HIGH_CONTRAST_THEME_ID)) { continue; } themes.add(theme); } return themes; }</code><technical_language>This appears inhibit user selecting high-contrast theme *display* (i.e. Platform OS) is in mode. ? this theme work this is set (BTW Paul tells GTK's display return false for this..</technical_language>

Target:
private List<ITheme> getCSSThemes(boolean highContrastMode) { List<ITheme> themes = new ArrayList<ITheme>(); for (ITheme theme : engine.getThemes()) { if (!highContrastMode && !Util.isGtk() && theme.getId().equals(E4Application.HIGH_CONTRAST_THEME_ID)) { continue; } themes.add(theme); } return themes; }
Source:
<code>public void testWorkManagerRunWorkInFailureOperation() throws InterruptedException, OperationException { Work failWork = new FailingWork(10); WorkManager wm = Framework.getService(WorkManager.class); wm.schedule(failWork); assertTrue(wm.awaitCompletion(2000, TimeUnit.MILLISECONDS)); Map<String, Serializable> params = new HashMap<>(); JSONBlob result = (JSONBlob) service.run(ctx, WorkManagerRunWorkInFailure.ID, params); assertNotNull(result); <START> assertEquals("[{\"total\":1,\"success\":0}]", result.getString()); <END> result = (JSONBlob) service.run(ctx, WorkManagerRunWorkInFailure.ID, params); assertNotNull(result); assertEquals("[{\"total\":0,\"success\":0}]", result.getString()); }</code><technical_language>JSON a HashMap, order is guaranteed. do JSON-level checks</technical_language>

Target:
public void testWorkManagerRunWorkInFailureOperation() throws Exception { Work failWork = new FailingWork(10); WorkManager wm = Framework.getService(WorkManager.class); wm.schedule(failWork); assertTrue(wm.awaitCompletion(2000, TimeUnit.MILLISECONDS)); Map<String, Serializable> params = new HashMap<>(); JSONBlob result = (JSONBlob) service.run(ctx, WorkManagerRunWorkInFailure.ID, params); assertNotNull(result); JSONAssert.assertEquals("{\"total\":1,\"success\":0}", result.getString(), true); result = (JSONBlob) service.run(ctx, WorkManagerRunWorkInFailure.ID, params); assertNotNull(result); JSONAssert.assertEquals("{\"total\":0,\"success\":0}", result.getString(), true); }
Source:
<code>public void startLoading(final boolean forceLoad) { super.startLoading(forceLoad); initTabs(); currentInfo = null; if (currentWorker != null) { currentWorker.dispose(); } currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe((@NonNull StreamInfo result) -> { isLoading.set(false); <START> if (result.getAgeLimit() != NO_AGE_LIMIT) { <END> onError(new RestrictedVideoException()); } else { currentInfo = result; handleResult(result); showContent(); } }, (@NonNull Throwable throwable) -> { isLoading.set(false); onError(throwable); }); }</code><technical_language>I understand checking if user disabled restricted videos</technical_language>

Target:
public void startLoading(final boolean forceLoad) { super.startLoading(forceLoad); initTabs(); currentInfo = null; if (currentWorker != null) { currentWorker.dispose(); } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe((@NonNull final StreamInfo result) -> { isLoading.set(false); if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( getString(R.string.show_age_restricted_content), false)) { hideAgeRestrictedContent(); } else { currentInfo = result; handleResult(result); showContent(); } }, (@NonNull final Throwable throwable) -> { isLoading.set(false); onError(throwable); }); }
Source:
<code>public boolean matches(Descriptor other) { if (!mode.equals(other.mode) || (argCount != other.argCount)) { return false; } for (int i = 0; i < argCount; i++) { if (!argTypes[i].isSameTypeOrFamily(other.argTypes[i])) { return false; } if (!exprTypes[i].equals(other.exprTypes[i])) { return false; } } <START> if (unscaled != other.unscaled) { <END> return false; } return true; }</code><technical_language>Check args</technical_language>

Target:
public boolean matches(Descriptor other) { if (!mode.equals(other.mode) || (argCount != other.argCount)) { return false; } if (unscaled != other.unscaled) { return false; } for (int i = 0; i < argCount; i++) { if (!argTypes[i].isSameTypeOrFamily(other.argTypes[i])) { return false; } if (!exprTypes[i].equals(other.exprTypes[i])) { return false; } } return true; }
Source:
<code>public void testUserPrivacyConsentNotRequired_UserConfigurationOverrideByRemoteParams() throws Exception { JSONObject remoteParams = new JSONObject(); <START> remoteParams.put("requires_user_privacy_consent", false); <END> ShadowOneSignalRestClient.setRemoteParamsGetHtmlResponse(remoteParams); OneSignal.setRequiresUserPrivacyConsent(true); OneSignalInit(); threadAndTaskWait(); assertFalse(OneSignal.requiresUserPrivacyConsent()); }</code><technical_language>is a method for this ShadowOneSignalRestClient setRemoteParamsRequirePrivacyConsent</technical_language>

Target:
public void testUserPrivacyConsentNotRequired_UserConfigurationOverrideByRemoteParams() throws Exception { ShadowOneSignalRestClient.setRemoteParamsRequirePrivacyConsent(false); OneSignal.setRequiresUserPrivacyConsent(true); OneSignalInit(); threadAndTaskWait(); assertFalse(OneSignal.requiresUserPrivacyConsent()); }
Source:
<code>public static ICElementHandle[] findAllDefinitions(IIndex index, IBinding binding) throws CoreException { if (binding != null) { IIndexName[] defs= index.findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); <START> Set<ICElementHandle> result = new HashSet<>(); <END> for (IIndexName in : defs) { ICElementHandle definition= getCElementForName((ICProject) null, index, in); if (definition != null) { result.add(definition); } } return result.toArray(new ICElementHandle[result.size()]); } return EMPTY_ELEMENT_ARRAY; }</code><technical_language>LinkedHashSet preserve order</technical_language>

Target:
public static ICElementHandle[] findAllDefinitions(IIndex index, IBinding binding) throws CoreException { if (binding != null) { IIndexName[] defs= index.findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); Set<ICElementHandle> result = new LinkedHashSet<>(); for (IIndexName in : defs) { ICElementHandle definition= getCElementForName((ICProject) null, index, in); if (definition != null) { result.add(definition); } } return result.toArray(new ICElementHandle[result.size()]); } return EMPTY_ELEMENT_ARRAY; }
Source:
<code>public KubernetesLeaderElector( NamespacedKubernetesClient kubernetesClient, String namespace, KubernetesLeaderElectionConfiguration leaderConfig, <START> LeaderCallbackHandler leaderCallbackHandler) { <END> super(kubernetesClient, new LeaderElectionConfigBuilder() .withName(leaderConfig.getConfigMapName()) .withLeaseDuration(leaderConfig.getLeaseDuration()) .withLock(new ConfigMapLock(namespace, leaderConfig.getConfigMapName(), LOCK_IDENTITY)) .withRenewDeadline(leaderConfig.getRenewDeadline()) .withRetryPeriod(leaderConfig.getRetryPeriod()) .withLeaderCallbacks(new LeaderCallbacks( leaderCallbackHandler::isLeader, leaderCallbackHandler::notLeader, newLeader -> LOG.info("New leader elected {}.", newLeader) )) .build()); LOG.info("Create KubernetesLeaderElector with lock identity {}.", leaderConfig.getConfigMapName(), LOCK_IDENTITY); }</code><technical_language>I missing tests for this class</technical_language>

Target:
public KubernetesLeaderElector( NamespacedKubernetesClient kubernetesClient, String namespace, KubernetesLeaderElectionConfiguration leaderConfig, LeaderCallbackHandler leaderCallbackHandler) { final LeaderElectionConfig leaderElectionConfig = new LeaderElectionConfigBuilder() .withName(leaderConfig.getConfigMapName()) .withLeaseDuration(leaderConfig.getLeaseDuration()) .withLock(new ConfigMapLock(namespace, leaderConfig.getConfigMapName(), leaderConfig.getLockIdentity())) .withRenewDeadline(leaderConfig.getRenewDeadline()) .withRetryPeriod(leaderConfig.getRetryPeriod()) .withLeaderCallbacks(new LeaderCallbacks( leaderCallbackHandler::isLeader, leaderCallbackHandler::notLeader, newLeader -> LOG.info("New leader elected for {}.", newLeader, leaderConfig.getConfigMapName()) )) .build(); internalLeaderElector = new LeaderElector<>(kubernetesClient, leaderElectionConfig); LOG.info("Create KubernetesLeaderElector with lock identity {}.", leaderConfig.getConfigMapName(), leaderConfig.getLockIdentity()); }
Source:
<code>public boolean accept(final ExecutableElement beanGetter, final MethodModel methodModel, final String contextType) { final Optional<DeclaredType> returnTypeOptional = collectionTypeReturnType(beanGetter); if (returnTypeOptional.isPresent()) { final DeclaredType x = returnTypeOptional.get(); final String uncheckedType = x.asElement().getSimpleName().toString(); final boolean isCollection = asList("Set", "List").contains(uncheckedType) && x.getTypeArguments().size() == 1; if (isCollection) { final DeclaredType declaredType = (DeclaredType) x.getTypeArguments().get(0); final TypeElement classInList = (TypeElement) declaredType.asElement(); final boolean isSphereEnumeration = classInList.getInterfaces().stream() .map(i -> (DeclaredType) i) .map(i -> (TypeElement) i.asElement()) .filter(i -> i.getQualifiedName().toString().equals(SphereEnumeration.class.getCanonicalName())).findFirst() .map(xs -> true).orElse(false); if (isSphereEnumeration) { final String typeParameterName = declaredType.asElement().getSimpleName().toString(); methodModel.setReturnType("SphereEnumerationCollectionQueryModel<" + contextType + ", " + typeParameterName + ">"); builder.addImport("io.sphere.sdk.queries.SphereEnumerationCollectionQueryModel"); return true; } } <START> } <END> return false; }</code><technical_language>Split method</technical_language>

Target:
public boolean accept(final ExecutableElement beanGetter, final MethodModel methodModel, final String contextType) { final Optional<DeclaredType> returnTypeOptional = collectionTypeReturnType(beanGetter); if (returnTypeOptional.isPresent()) { final DeclaredType returnType = returnTypeOptional.get(); final DeclaredType declaredType = (DeclaredType) returnType.getTypeArguments().get(0); final TypeElement classInList = (TypeElement) declaredType.asElement(); if (isSphereEnumeration(classInList)) { applyEnumerationRule(methodModel, contextType, declaredType); return true; } } return false; }
Source:
<code>public void testIsThreadActiveRange() { KernelAnalysisModule module = checkNotNull(fModule); final long start = 45L; final long end = 65L; Set<Integer> tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, start, end); assertNotNull(tids); assertEquals(ImmutableSet.of(11, 21, 30), tids); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 0, 0); <START> assertTrue(tids.isEmpty()); <END> tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 123456789L, 1234567890L); assertTrue(tids.isEmpty()); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 0, 10L); assertNotNull(tids); assertTrue(tids.isEmpty()); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 70, 123456L); assertNotNull(tids); assertEquals(ImmutableSet.of(11, 20, 21), tids); }</code><technical_language>assertNotNull before</technical_language>

Target:
public void testIsThreadActiveRange() { KernelAnalysisModule module = checkNotNull(fModule); final long start = 45L; final long end = 65L; Set<Integer> tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, start, end); assertEquals(ImmutableSet.of(11, 21, 30), tids); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 0, 0); assertTrue(tids.isEmpty()); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 123456789L, 1234567890L); assertTrue(tids.isEmpty()); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 0, 10L); assertTrue(tids.isEmpty()); tids = KernelThreadInformationProvider.getActiveThreadsForRange(module, 70, 123456L); assertEquals(ImmutableSet.of(11, 20, 21), tids); }
Source:
<code>public void initialize(Analyzer analyzer) { if ( this.analyzer != null ) { <START> throw new AssertionFailure( "An analyzer reference has been initialized more than once." ); <END> } this.analyzer = analyzer; }</code><technical_language>include name of analyzer analyzer if defined</technical_language>

Target:
public void initialize(Analyzer analyzer) { if ( this.analyzer != null ) { throw new AssertionFailure( "An analyzer reference has been initialized more than once:" + this ); } this.analyzer = analyzer; }
Source:
<code>public boolean accepts( Event<?> evt ) { return applicationStatusSource.getSystemStatus().isNexusStarted() && ( evt instanceof RepositoryRegistryRepositoryEvent ) <START> || ( evt instanceof RepositoryConfigurationUpdatedEvent ); <END> }</code><technical_language>put isNexusStarted method call "evt instanceof ..." checks - this perform avoid calling synchronous method for other Nexus events. add brackets clear status check applies events registry one</technical_language>

Target:
public boolean accepts( Event<?> evt ) { return ( ( evt instanceof RepositoryRegistryRepositoryEvent ) || ( evt instanceof RepositoryConfigurationUpdatedEvent ) ) && applicationStatusSource.getSystemStatus().isNexusStarted(); }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Handler().postDelayed(new Runnable() { @Override public void run() { <START> Intent launch_piano_activity = new Intent(SplashScreen.this, PianoActivity.class); <END> startActivity(launch_piano_activity); finish(); } }, SPLASH_TIME_OUT); }</code><technical_language>Java coding-standard: name variables in CamelCase... launchPianoActivity in this case</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Handler().postDelayed(new Runnable() { @Override public void run() { Intent launchpianoactivity = new Intent(SplashScreen.this, PianoActivity.class); startActivity(launchpianoactivity); finish(); } }, SPLASH_TIME_OUT); }
Source:
<code>public void testConnectionFailed() throws Exception { boolean expected = false; NettyClientBase client = null; try { int port = server.getListenAddress().getPort() + 1; RpcConnectionPool.RpcConnectionKey rpcConnectionKey = new RpcConnectionPool.RpcConnectionKey( RpcUtils.getConnectAddress(new InetSocketAddress("127.0.0.1", port)), DummyProtocol.class, false); <START> client = new BlockingRpcClient(rpcConnectionKey, retries); <END> client.close(); fail("Connection should be failed."); } catch (ConnectException ce) { expected = true; } catch (Throwable ce){ if (client != null) { client.close(); } fail(); } assertTrue(expected); }</code><technical_language>This code block throw ConnectException. add acquire connection this</technical_language>

Target:
public void testConnectionFailed() throws Exception { NettyClientBase client = null; try { int port = server.getListenAddress().getPort() + 1; RpcConnectionPool.RpcConnectionKey rpcConnectionKey = new RpcConnectionPool.RpcConnectionKey( RpcUtils.getConnectAddress(new InetSocketAddress("127.0.0.1", port)), DummyProtocol.class, false); client = new BlockingRpcClient(rpcConnectionKey, retries); assertFalse(client.acquire(RpcConnectionPool.DEFAULT_TIMEOUT)); client.close(); } catch (Throwable ce){ if (client != null) { client.close(); } fail(); } }