auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public List<Field> getLayoutFieldsToDelete() { try { if (notStrictFieldLayoutRowSyntaxValidator == null) { notStrictFieldLayoutRowSyntaxValidator = new NotStrictFieldLayoutRowSyntaxValidator(this.contentType, this.fields); notStrictFieldLayoutRowSyntaxValidator.validate(); } return notStrictFieldLayoutRowSyntaxValidator.getFieldsToRemove(); } catch (FieldLayoutValidationException e) { <START> throw new DotRuntimeException(e); <END> } }</code><technical_language>log Identifier name of Content Type in error</technical_language>

Target:
public List<Field> getLayoutFieldsToDelete() { try { if (notStrictFieldLayoutRowSyntaxValidator == null) { notStrictFieldLayoutRowSyntaxValidator = new NotStrictFieldLayoutRowSyntaxValidator(this.contentType, this.fields); notStrictFieldLayoutRowSyntaxValidator.validate(); } return notStrictFieldLayoutRowSyntaxValidator.getFieldsToRemove(); } catch (FieldLayoutValidationException e) { Logger.error(FieldLayout.class, e.getMessage()); throw new DotRuntimeException(e); } }
Source:
<code>public void testJsonConstructorAnnotation() { <START> try { <END> ClassFactory<DemoModel> factory = ClassFactory.get(DemoModel.class); DemoModel demoModel = factory.newInstance(); Assert.assertEquals(0, demoModel.s); Assert.assertEquals(0, demoModel.i); Assert.assertEquals(Integer.valueOf(0), demoModel.i2); Assert.assertEquals("", demoModel.str); Assert.assertNotNull("Interface parameters should be passed proxy objects.", demoModel.list); Assert.assertEquals("Enum parameters should be passed the first enum value.", Enum.VALUE, demoModel.testEnum); Assert.assertNotNull("Other objects should be created using a no-arg constructor.", demoModel.date); } catch (IllegalArgumentException e) { Assert.fail("Should be able to construct ClassFactory."); } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { Assert.fail("Should be able to construct object using ClassFactory."); } }</code><technical_language>Delete try/catches. exception fails test case</technical_language>

Target:
@Test public void testJsonConstructorAnnotation() throws IllegalAccessException, InstantiationException, InvocationTargetException { ClassFactory<DemoModel> factory = ClassFactory.get(DemoModel.class); DemoModel demoModel = factory.newInstance(); Assert.assertEquals(0, demoModel.s); Assert.assertEquals(0, demoModel.i); Assert.assertEquals(Integer.valueOf(0), demoModel.i2); Assert.assertEquals("", demoModel.str); Assert.assertNotNull("Interface parameters should be passed proxy objects.", demoModel.list); Assert.assertEquals("Enum parameters should be passed the first enum value.", Enum.VALUE, demoModel.testEnum); Assert.assertNotNull("Other objects should be created using a no-arg constructor.", demoModel.date); }
Source:
<code>public void setUp() { n = new CacheNotifierImpl(); mockCache = mock(EncoderCache.class); EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class); when(mockCache.getCacheManager()).thenReturn(cacheManager); when(mockCache.getAdvancedCache()).thenReturn(mockCache); when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.DEFAULT_KEY); when(mockCache.getValueDataConversion()).thenReturn(DataConversion.DEFAULT_VALUE); when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING); ComponentRegistry componentRegistry = mock(ComponentRegistry.class); when(mockCache.getComponentRegistry()).thenReturn(componentRegistry); MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry(); when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry); mockRegistry.registerMocks(RpcManager.class, StreamingMarshaller.class, CancellationService.class, CommandsFactory.class, Encoder.class); Configuration config = new ConfigurationBuilder().memory().storageType(StorageType.OBJECT).build(); TestingUtil.inject(n, mockCache, cdl, config, mockRegistry, mock(InternalEntryFactory.class), mock(ClusterEventManager.class), mock(KeyPartitioner.class), <START> TestingUtil.named(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR, new WithinThreadExecutor())); <END> cl = new PrimaryOwnerCacheListener(); n.start(); n.addListener(cl); ctx = new NonTxInvocationContext(null); }</code><technical_language>executor needed</technical_language>

Target:
public void setUp() { n = new CacheNotifierImpl(); mockCache = mock(EncoderCache.class); EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class); when(mockCache.getCacheManager()).thenReturn(cacheManager); when(mockCache.getAdvancedCache()).thenReturn(mockCache); when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.DEFAULT_KEY); when(mockCache.getValueDataConversion()).thenReturn(DataConversion.DEFAULT_VALUE); when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING); ComponentRegistry componentRegistry = mock(ComponentRegistry.class); when(mockCache.getComponentRegistry()).thenReturn(componentRegistry); MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry(); when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry); mockRegistry.registerMocks(RpcManager.class, StreamingMarshaller.class, CancellationService.class, CommandsFactory.class, Encoder.class); Configuration config = new ConfigurationBuilder().memory().storageType(StorageType.OBJECT).build(); TestingUtil.inject(n, mockCache, cdl, config, mockRegistry, mock(InternalEntryFactory.class), mock(ClusterEventManager.class), mock(KeyPartitioner.class)); cl = new PrimaryOwnerCacheListener(); n.start(); n.addListener(cl); ctx = new NonTxInvocationContext(null); }
Source:
<code>public static Expression create(Expression expression, PDataType toType) throws SQLException { final PDataType dataType = expression.getDataType(); <START> if (toType != null && !dataType.isCoercibleTo(toType)) { <END> throw new TypeMismatchException(dataType, toType, expression.toString()); } return toType == dataType ? expression : expression instanceof LiteralExpression ? LiteralExpression.newConstant(((LiteralExpression)expression).getValue(), toType) : new CoerceExpression(expression, toType); }</code><technical_language>move isCoercibleTo check CoerceExpression.create() visit method for CastParseNode in ExpressionCompiler. cases able coerce, allowed</technical_language>

Target:
public static Expression create(Expression expression, PDataType toType) throws SQLException { return toType == expression.getDataType() ? expression : expression instanceof LiteralExpression ? LiteralExpression.newConstant(((LiteralExpression)expression).getValue(), toType) : new CoerceExpression(expression, toType); }
Source:
<code>public void onBookmarkClick(boolean bookmarkSaved) { if (getPage() == null) { return; } if (bookmarkSaved) { SavedPage.markPageToSave(getTitle()); FeedbackUtil.showMessage(getActivity(), R.string.snackbar_saving_page); } else { <START> deleteBookmark(); <END> } }</code><technical_language>a SavedPage.markPageToDelete()? (I implementation in a card though.)</technical_language>

Target:
public void onBookmarkClick(boolean bookmarkSaved) { if (getPage() == null) { return; } if (bookmarkSaved) { saveBookmark(); } else { deleteBookmark(); } }
Source:
<code>public List<String> getTemplateUrl(UUID templateId) throws GeneralSecurityException, IOException { Template template = repository.findOne(templateId); if (template == null) { <START> throw new IllegalArgumentException("team.invalid"); <END> } Long expiration = (System.currentTimeMillis() / 1000) + 7200; return storage.exposeFilesInFolder(bucket, template.filePath(), expiration); }</code><technical_language>team</technical_language>

Target:
public List<String> getTemplateUrl(UUID templateId) throws GeneralSecurityException, IOException { Template template = repository.findOne(templateId); if (template == null) { throw new IllegalArgumentException("template.invalid"); } Long expiration = (System.currentTimeMillis() / 1000) + 7200; return storage.exposeFilesInFolder(bucket, template.filePath(), expiration); }
Source:
<code>protected void write( FeatureCollectionResponse featureCollection, OutputStream output, Operation getFeature) throws IOException, ServiceException { GetFeatureType getFeatureType = (GetFeatureType) getFeature.getParameters()[0]; Integer resolution = 256; try { resolution = Integer.parseInt(getFeatureType.getResolution()); } catch (NumberFormatException e) { } FeatureCollection collection = featureCollection.getFeatures().get(0); final Rectangle paintArea = new Rectangle(resolution, resolution); CoordinateReferenceSystem refSys = collection .getSchema() .getGeometryDescriptor() .getType() .getCoordinateReferenceSystem(); ReferencedEnvelope area = ReferencedEnvelope.create(collection.getBounds(), refSys); Pipeline pipeline = getPipeline(area, paintArea, refSys, resolution / 32); VectorTileEncoder encoder = new VectorTileEncoderNoClip(resolution, resolution / 32, false); try (FeatureIterator<SimpleFeature> features = collection.features()) { while (features.hasNext()) { SimpleFeature feature = features.next(); Geometry geom = (Geometry) feature.getDefaultGeometryProperty().getValue(); Geometry finalGeom = finalGeom = pipeline.execute(geom); final String layerName = feature.getName().getLocalPart(); final Map<String, Object> properties = getProperties(feature); if (finalGeom.getCoordinates().length > 0) encoder.addFeature(layerName, properties, finalGeom); } output.write(encoder.encode()); } catch (Exception e) { <START> e.printStackTrace(); <END> } }</code><technical_language>No, eating exceptions printing standard error is good. Ideally "fail fast". Is vectortiles module handling a similar situation, if so, how</technical_language>

Target:
protected void write( FeatureCollectionResponse featureCollection, OutputStream output, Operation getFeature) throws IOException, ServiceException { GetFeatureType getFeatureType = (GetFeatureType) getFeature.getParameters()[0]; Integer resolution = getFeatureType.getResolution() != null ? getFeatureType.getResolution() : 256; FeatureCollection collection = featureCollection.getFeatures().get(0); final Rectangle paintArea = new Rectangle(resolution, resolution); CoordinateReferenceSystem refSys = collection .getSchema() .getGeometryDescriptor() .getType() .getCoordinateReferenceSystem(); ReferencedEnvelope area = ReferencedEnvelope.create( tileData.isTileRequest() ? envelopeFromTileRequestData() : collection.getBounds(), refSys); Pipeline pipeline = getPipeline(area, paintArea, refSys, resolution / 32); VectorTileEncoder encoder = new VectorTileEncoderNoClip(resolution, resolution / 32, false); try (FeatureIterator<SimpleFeature> features = collection.features()) { while (features.hasNext()) { SimpleFeature feature = features.next(); Geometry geom = (Geometry) feature.getDefaultGeometryProperty().getValue(); Geometry finalGeom = finalGeom = pipeline.execute(geom); final String layerName = feature.getName().getLocalPart(); final Map<String, Object> properties = getProperties(feature); if (finalGeom.getCoordinates().length > 0) encoder.addFeature(layerName, properties, finalGeom); } output.write(encoder.encode()); } catch (Exception e) { throw new RuntimeException(e); } }
Source:
<code>public List<ClientScopeModel> getClientScopes() { if (isUpdated()) return updated.getClientScopes(); <START> List<String> clientTemplates = cached.getClientScopes(); <END> if (clientTemplates.isEmpty()) return Collections.EMPTY_LIST; List<ClientScopeModel> apps = new LinkedList<ClientScopeModel>(); for (String id : clientTemplates) { ClientScopeModel model = cacheSession.getClientScopeById(id, this); if (model == null) { throw new IllegalStateException("Cached clientemplate not found: " + id); } apps.add(model); } return Collections.unmodifiableList(apps); }</code><technical_language>clientScopes</technical_language>

Target:
public List<ClientScopeModel> getClientScopes() { if (isUpdated()) return updated.getClientScopes(); List<String> clientScopes = cached.getClientScopes(); if (clientScopes.isEmpty()) return Collections.EMPTY_LIST; List<ClientScopeModel> apps = new LinkedList<ClientScopeModel>(); for (String id : clientScopes) { ClientScopeModel model = cacheSession.getClientScopeById(id, this); if (model == null) { throw new IllegalStateException("Cached clientScope not found: " + id); } apps.add(model); } return Collections.unmodifiableList(apps); }
Source:
<code>private static void saveSpoilersWithoutTransaction(final Geocache cache) { final List<Image> spoilers = cache.getSpoilers(); if (CollectionUtils.isNotEmpty(spoilers)) { final String geocode = cache.getGeocode(); <START> database.delete(dbTableSpoilers, "geocode = ?", new String[]{geocode}); <END> final SQLiteStatement insertSpoiler = PreparedStatement.INSERT_SPOILER.getStatement(); final long timestamp = System.currentTimeMillis(); for (final Image spoiler : spoilers) { insertSpoiler.bindString(1, geocode); insertSpoiler.bindLong(2, timestamp); insertSpoiler.bindString(3, spoiler.getUrl()); insertSpoiler.bindString(4, StringUtils.defaultIfBlank(spoiler.title, "")); final String description = spoiler.getDescription(); if (StringUtils.isNotBlank(description)) { insertSpoiler.bindString(5, description); } else { insertSpoiler.bindNull(5); } insertSpoiler.executeInsert(); } } }</code><technical_language>wondering if deletion performance benefit a preparedStatement. (The existing prepared statements introduced avoid database query cache overflow, of performance reasons)</technical_language>

Target:
private static void saveSpoilersWithoutTransaction(final Geocache cache) { if (cache.hasSpoilersSet()) { final String geocode = cache.getGeocode(); final SQLiteStatement remove = PreparedStatement.REMOVE_SPOILERS.getStatement(); remove.bindString(1, cache.getGeocode()); remove.execute(); final SQLiteStatement insertSpoiler = PreparedStatement.INSERT_SPOILER.getStatement(); final long timestamp = System.currentTimeMillis(); for (final Image spoiler : cache.getSpoilers()) { insertSpoiler.bindString(1, geocode); insertSpoiler.bindLong(2, timestamp); insertSpoiler.bindString(3, spoiler.getUrl()); insertSpoiler.bindString(4, StringUtils.defaultIfBlank(spoiler.title, "")); final String description = spoiler.getDescription(); if (StringUtils.isNotBlank(description)) { insertSpoiler.bindString(5, description); } else { insertSpoiler.bindNull(5); } insertSpoiler.executeInsert(); } } }
Source:
<code>public static ByteBuf generatePacket(long ledgerId, long entryId, long lastAddConfirmed, long length, byte[] data, int offset, int len) { DigestManager dm = null; try { dm = DigestManager.instantiate(ledgerId, new byte[2], CRC32); } catch (GeneralSecurityException gse) { <START> <END> } return dm.computeDigestAndPackageForSending(entryId, lastAddConfirmed, length, Unpooled.wrappedBuffer(data, offset, len)); }</code><technical_language>Rethrow log</technical_language>

Target:
public static ByteBuf generatePacket(long ledgerId, long entryId, long lastAddConfirmed, long length, byte[] data, int offset, int len) throws GeneralSecurityException { DigestManager dm = DigestManager.instantiate(ledgerId, new byte[2], CRC32); return dm.computeDigestAndPackageForSending(entryId, lastAddConfirmed, length, Unpooled.wrappedBuffer(data, offset, len)); }
Source:
<code>public final SpawnPrim initialize(final VM vm) { super.initialize(vm); this.onExec = insert( Breakpoints.create(sourceSection, BreakpointType.ACTIVITY_ON_EXEC, vm)); this.forkJoinPool = vm.getForkJoinPool(); this.processesPool = vm.getProcessPool(); this.threadPool = vm.getThreadPool(); <START> thrower = new ExceptionSignalingNode("NotAValue", <END> "signalWith:", sourceSection); return this; }</code><technical_language>want factory methods for common exceptions. magic strings codebase is ideal</technical_language>

Target:
public final SpawnPrim initialize(final VM vm) { super.initialize(vm); onExec = insert(Breakpoints.create(sourceSection, BreakpointType.ACTIVITY_ON_EXEC, vm)); notAValue = insert(ExceptionSignalingNode.createNotAValueNode(sourceSection)); forkJoinPool = vm.getForkJoinPool(); processesPool = vm.getProcessPool(); threadPool = vm.getThreadPool(); return this; }
Source:
<code>SolrQuery getQuery() { StringBuilder querySB = new StringBuilder(); if (StringUtils.isNotBlank(afterDate) && StringUtils.isNotBlank(beforeDate)) { querySB.append("[").append(afterDate).append(" TO ").append(beforeDate).append("]"); } else if (StringUtils.isNotBlank(afterDate) && StringUtils.isBlank(beforeDate)) { querySB.append("[").append(afterDate).append(" TO NOW").append("]"); } else if (StringUtils.isBlank(afterDate) && StringUtils.isNotBlank(beforeDate)) { querySB.append("[").append(EARLY_TIME).append(" TO ").append(beforeDate).append("]"); } SolrQuery query; if (querySB.length() > 0) { query = new SolrQuery(field + ":" + querySB.toString()); } else { query = new SolrQuery("*:*"); } SortClause sort = new SortClause("metacard.created_tdt", ORDER.desc); query.setSort(sort); query.addSort(new SortClause("id_txt", ORDER.desc)); query.setParam(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark); <START> query.setRows(Math.max(PAGE_SIZE, WRITE_TXN_SIZE)); <END> return query; }</code><technical_language>question: this PAGE_SIZE WRITE_TXN_SIZE is smaller PAGE_SIZE? Is this in case updates constants</technical_language>

Target:
SolrQuery getQuery() { StringBuilder querySB = new StringBuilder(); if (StringUtils.isNotBlank(afterDate) && StringUtils.isNotBlank(beforeDate)) { querySB.append("[").append(afterDate).append(" TO ").append(beforeDate).append("]"); } else if (StringUtils.isNotBlank(afterDate) && StringUtils.isBlank(beforeDate)) { querySB.append("[").append(afterDate).append(" TO NOW").append("]"); } else if (StringUtils.isBlank(afterDate) && StringUtils.isNotBlank(beforeDate)) { querySB.append("[").append(EARLY_TIME).append(" TO ").append(beforeDate).append("]"); } SolrQuery query; if (querySB.length() > 0) { query = new SolrQuery(field + ":" + querySB.toString()); } else { query = new SolrQuery("*:*"); } SortClause sort = new SortClause("metacard.modified_tdt", ORDER.desc); query.setSort(sort); query.addSort(new SortClause("id_txt", ORDER.desc)); query.setParam(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark); query.setRows(PAGE_SIZE); return query; }
Source:
<code>public SynchronizationBackend(File syncFile, boolean throwErrors) throws IOException { int res; fSyncFile = syncFile; if (syncFile == null) { return; } if (!syncFile.exists()) { if (throwErrors) { <START> throw new IOException("Selected synchronization file does not exist"); END> } return; } if (syncFile.length() <= 0) { if (throwErrors) { throw new IOException("Invalid synchronization file selected, " + "target file is empty"); } return; } FileInputStream fis = new FileInputStream(syncFile); ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE); FileChannel fc = fis.getChannel(); buffer.clear(); fc.read(buffer); buffer.flip(); res = buffer.getInt(); if (res != SYNC_FILE_MAGIC_NUMBER) { fc.close(); fis.close(); throw new IOException("Selected file does not" + "look like a synchronization file"); } res = buffer.getInt(); if (res != MAJOR_VERSION) { fc.close(); fis.close(); throw new IOException("Select synchronization file is of an older " + "format. Synchronization will have to be computed again."); } res = buffer.getInt(); fc.close(); fis.close(); }</code><technical_language>If exception messages shown user, externalized. If not, nevermind</technical_language>

Target:
public SynchronizationBackend(File syncFile, boolean throwErrors) throws IOException { int res; fSyncFile = syncFile; if (syncFile == null) { return; } if (!syncFile.exists()) { if (throwErrors) { throw new IOException("Selected synchronization file does not exist"); } return; } if (syncFile.length() <= 0) { if (throwErrors) { throw new IOException("Invalid synchronization file selected, " + "target file is empty"); } return; } FileInputStream fis = new FileInputStream(syncFile); ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE); FileChannel fc = fis.getChannel(); buffer.clear(); fc.read(buffer); buffer.flip(); res = buffer.getInt(); if (res != SYNC_FILE_MAGIC_NUMBER) { fc.close(); fis.close(); throw new IOException("Selected file does not" + "look like a synchronization file"); } res = buffer.getInt(); if (res != FILE_VERSION) { fc.close(); fis.close(); throw new IOException("Select synchronization file is of an older " + "format. Synchronization will have to be computed again."); } res = buffer.getInt(); fc.close(); fis.close(); }
Source:
<code>private static File getTempDir() { File tempDir; if (System.getProperty("os.name").toLowerCase().equals("linux")){ <START> tempDir = new File("/var/tmp"); <END> }else { tempDir = new File(System.getProperty("java.io.tmpdir")); } if (tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite()) { return tempDir; } try { File tempFile = File.createTempFile("_ganttproject_autosave", ".empty"); tempDir = tempFile.getParentFile(); if (tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite()) { return tempDir; } } catch (IOException e) { GPLogger.getLogger(DocumentManager.class).log(Level.WARNING, "Can't get parent of the temp file", e); } GPLogger.getLogger(DocumentManager.class).warning("Failed to find temporary directory"); return null; }</code><technical_language>I understand need, however, careful working paths Java. /var/tmp exist, exist writable, permissions create if exist. Linux sysadmins want some other directory instead, is is hardcoded. Also, I doubt os.name is (lowercased) linux running Linux. Perhaps, more sense check if directory exists is writable in case of success, default temporary file directory</technical_language>

Target:
private static File getTempDir() { File tempDir; if (SystemUtils.IS_OS_LINUX ){ tempDir = new File("/var/tmp"); if (tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite()) { return tempDir; } } tempDir = new File(System.getProperty("java.io.tmpdir")); if (tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite()) { return tempDir; } try { File tempFile = File.createTempFile("_ganttproject_autosave", ".empty"); tempDir = tempFile.getParentFile(); if (tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite()) { return tempDir; } } catch (IOException e) { GPLogger.getLogger(DocumentManager.class).log(Level.WARNING, "Can't get parent of the temp file", e); } GPLogger.getLogger(DocumentManager.class).warning("Failed to find temporary directory"); return null; }
Source:
<code>protected boolean AddVmImages() { List<DiskImage> disks = DbFacade.getInstance().getDiskImageDAO().getAllForVm( getParameters().getVmStaticData().getvmt_guid()); if (disks.isEmpty() && !getParameters().getVmStaticData().getvmt_guid().equals(Guid.Empty)) { throw new VdcBLLException(VdcBllErrors.VM_TEMPLATE_CANT_LOCATE_DISKS_IN_DB); } DiskImageBase defBootDisk = LinqUtils.firstOrNull(getVmDisks(), new Predicate<DiskImageBase>() { @Override public boolean eval(DiskImageBase diskImageBase) { return diskImageBase.getboot(); } }); if (defBootDisk != null) { for (DiskImageBase diskImageBase : getVmDisks()) { if (diskImageBase != defBootDisk) diskImageBase.setboot(false); } } <START> return (disks.size()>0) ? ConcreteAddVmImages(disks.get(0).getId()): true; <END> }</code><technical_language>check isEmpty? please format this line</technical_language>

Target:
protected boolean AddVmImages() { List<DiskImage> disks = DbFacade.getInstance().getDiskImageDAO().getAllForVm( getParameters().getVmStaticData().getvmt_guid()); if (disks.isEmpty() && !getParameters().getVmStaticData().getvmt_guid().equals(Guid.Empty)) { throw new VdcBLLException(VdcBllErrors.VM_TEMPLATE_CANT_LOCATE_DISKS_IN_DB); } DiskImageBase defBootDisk = LinqUtils.firstOrNull(getVmDisks(), new Predicate<DiskImageBase>() { @Override public boolean eval(DiskImageBase diskImageBase) { return diskImageBase.getboot(); } }); if (defBootDisk != null) { for (DiskImageBase diskImageBase : getVmDisks()) { if (diskImageBase != defBootDisk) diskImageBase.setboot(false); } } return (!disks.isEmpty()) ? ConcreteAddVmImages(disks.get(0).getId()) : true; }
Source:
<code>private DefaultEnvironment buildEnvironment(EnvironmentType environmentType) { DefaultEnvironment defaultEnvironment = new DefaultEnvironment(environmentType); <START> defaultEnvironment.setup(); <END> return defaultEnvironment; }</code><technical_language>need do if calling loadProperties in public constructor, right? <LINK_0></technical_language>

Target:
private DefaultEnvironment buildEnvironment(EnvironmentType environmentType) { DefaultEnvironment defaultEnvironment = new DefaultEnvironment(environmentType); return defaultEnvironment; }
Source:
<code>private SelectionListener createListener() { final SelectionListener listener = new SelectionListener() { @Override public void <START> widgetSelected(SelectionEvent e) { <END> resetProperties(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; return listener; }</code><technical_language>final missing</technical_language>

Target:
private SelectionListener createListener() { final SelectionListener listener = new SelectionListener() { @Override public void widgetSelected(final SelectionEvent e) { resetProperties(); } @Override public void widgetDefaultSelected(final SelectionEvent e) { } }; return listener; }
Source:
<code>static ChannelStateWriteRequest write(long checkpointId, InputChannelInfo info, CloseableIterator<Buffer> iterator) { return new CheckpointInProgressRequest( "writeInput", checkpointId, writer -> { while (iterator.hasNext()) { Buffer buffer = iterator.next(); checkArgument(buffer.isBuffer()); writer.writeInput(info, buffer); } }, throwable -> { try { iterator.close(); } catch (Exception e) { final RuntimeException re = new RuntimeException("unable to close iterator", e); <START> re.addSuppressed(throwable); <END> throw re; } }, false); }</code><technical_language>this other around? throwable.addSuppressed(e)</technical_language>

Target:
static ChannelStateWriteRequest write(long checkpointId, InputChannelInfo info, CloseableIterator<Buffer> iterator) { return new CheckpointInProgressRequest( "writeInput", checkpointId, writer -> { while (iterator.hasNext()) { Buffer buffer = iterator.next(); try { checkArgument(buffer.isBuffer()); } catch (Exception e) { buffer.recycleBuffer(); throw e; } writer.writeInput(info, buffer); } }, throwable -> iterator.close(), false); }
Source:
<code>public ClientSession getClientSession(boolean transacted) throws Exception { log.debug("Creating new ActiveMQ session..."); ClientSessionFactory csf = this.getClientSessionFactory(); ClientSession session = transacted ? csf.createTransactedSession() : <START> csf.createSession(true, false); <END> log.debug("Created new ActiveMQ session: {}", session); return session; }</code><technical_language>change this here, flip flag in JobMessageReceiver true for transacted line 59: session = this.sessionFactory.getIngressSession(true); If a reason need control of these, interface wrapping this change flags set independently</technical_language>

Target:
public ClientSession getClientSession(boolean transacted) throws Exception { log.debug("Creating new ActiveMQ session..."); ClientSessionFactory csf = this.getClientSessionFactory(); ClientSession session = transacted ? csf.createTransactedSession() : csf.createSession(); log.debug("Created new ActiveMQ session: {}", session); return session; }
Source:
<code>public void setParent(@Nullable Node parent, @Nullable MethodYield methodYield) { if (parent != null) { if (parents.isEmpty()) { programState.constraints.forEach((sv, c) -> { if (parent.programState.getConstraint(sv) != c) { addConstraint(sv, c); } }); programState.values.forEach((s, sv) -> { if (parent.programState.getValue(s) != sv) { learnedSymbols.add(new LearnedValue(sv, s)); } }); } <START> if (parents.get(parent) == null) { <END> parents.put(parent, methodYield); } } }</code><technical_language>This factorized a call addParent</technical_language>

Target:
public void setParent(@Nullable Node parent, @Nullable MethodYield methodYield) { if (parent != null) { if (parents.isEmpty()) { programState.constraints.forEach((sv, c) -> { if (parent.programState.getConstraint(sv) != c) { addConstraint(sv, c); } }); programState.values.forEach((s, sv) -> { if (parent.programState.getValue(s) != sv) { learnedSymbols.add(new LearnedValue(sv, s)); } }); } addParent(parent, methodYield); } }
Source:
<code>public Object runInTransaction() { try { EntityManager em = ensureEntityManager(entityManagerFactory); Object result = context.proceed(); em.flush(); <START> EntityManagerHolder.getInstance().getThreadLocal().set(null); <END> return result; } catch (Exception e) { logger.error("Failed to run operation in a new transaction", e); throwable = e; return null; } }</code><technical_language>persistent context long a single dao api call in case of running action in suppress/no transaction</technical_language>

Target:
public Object runInTransaction() { try { EntityManager em = ensureEntityManager(entityManagerFactory); Object result = context.proceed(); if (!readOnly) { em.flush(); } EntityManagerHolder.getInstance().getThreadLocal().set(null); return result; } catch (Exception e) { logger.error("Failed to run operation in a new transaction", e); throwable = e; return null; } }
Source:
<code>public boolean equals(Object obj) { <START> if (obj == null || !(obj instanceof AsyncBase)) { <END> return false; } return ((AsyncBase) obj).naturalKey.equals(naturalKey); }</code><technical_language>check object classes equal</technical_language>

Target:
public boolean equals(Object obj) { if (obj == null || !(obj instanceof AsyncBase) || this.getClass() != obj.getClass()) { return false; } return ((AsyncBase) obj).naturalKey.equals(naturalKey); }
Source:
<code>public CompletionStage<Void> close() { if ( closed.compareAndSet( false, true ) ) { nettyChannelTracker.prepareToCloseChannels(); <START> CompletableFuture<Void> allPoolClosedFuture = CompletableFuture.allOf( <END> pools.entrySet().stream().map( entry -> { BoltServerAddress address = entry.getKey(); ExtendedChannelPool pool = entry.getValue(); log.info( "Closing connection pool towards %s", address ); return closePool( pool ).toCompletableFuture(); } ).toArray( CompletableFuture[]::new ) ); allPoolClosedFuture.whenComplete( ( ignored, pollCloseError ) -> { pools.clear(); if ( !ownsEventLoopGroup ) { completedWithNullIfNonError( closeFuture, pollCloseError ); } else { eventLoopGroup().shutdownGracefully( 200, 15_000, TimeUnit.MILLISECONDS ); Futures.asCompletionStage( eventLoopGroup().terminationFuture() ).whenComplete( ( ignore, eventLoopGroupTerminationError ) -> { CompletionException combinedErrors = combineErrors( pollCloseError, eventLoopGroupTerminationError ); completedWithNullIfNonError( closeFuture, combinedErrors ); } ); } } ); } return closeFuture; }</code><technical_language>extract creation of this CompletableFuture in a method</technical_language>

Target:
public CompletionStage<Void> close() { if ( closed.compareAndSet( false, true ) ) { nettyChannelTracker.prepareToCloseChannels(); CompletableFuture<Void> allPoolClosedFuture = closeAllPools(); allPoolClosedFuture.whenComplete( ( ignored, pollCloseError ) -> { pools.clear(); if ( !ownsEventLoopGroup ) { completeWithNullIfNoError( closeFuture, pollCloseError ); } else { shutdownEventLoopGroup( pollCloseError ); } } ); } return closeFuture; }
Source:
<code>public void testDefaultOperation() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(AvoidStaticImportCheck.class); final String[] expected = { "23:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "25:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), <START> "26:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), <END> "27:27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "28:27: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), "29:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.E"), "30:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), "31:113: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), "32:124: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImportDefault.java"), expected); }</code><technical_language>This is scope of issue, please - this import in file duplicated violation, please remove them</technical_language>

Target:
public void testDefaultOperation() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(AvoidStaticImportCheck.class); final String[] expected = { "23:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "25:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "26:27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "27:27: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), "28:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.E"), "29:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), "30:113: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), "31:124: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImportDefault.java"), expected); }
Source:
<code>public boolean perform( Metadata metadata ) throws MetadataException { if ( metadata == null ) { return false; } List<Plugin> plugins = metadata.getPlugins(); for ( Plugin p : plugins ) { if ( p.getArtifactId().equals( plugin.getArtifactId() ) ) { if ( isPluginPrefixAndNameEquals( p, plugin ) ) { <START> p.setName( plugin.getName() ); <END> return false; } } } plugins.add( plugin ); Collections.sort( plugins, pluginComparator ); return true; }</code><technical_language>I if is a good merge plugins prefix:artifactId names, choose new name instead of original one</technical_language>

Target:
public boolean perform( Metadata metadata ) throws MetadataException { if ( metadata == null ) { return false; } List<Plugin> plugins = metadata.getPlugins(); for ( Plugin p : plugins ) { if ( p.getArtifactId().equals( plugin.getArtifactId() ) ) { if ( isPluginPrefixAndArtifactIdEquals( p, plugin ) ) { p.setName( plugin.getName() ); return false; } } } plugins.add( plugin ); Collections.sort( plugins, pluginComparator ); return true; }
Source:
<code>public void setFile(AbstractFile file) { WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); <START> abstractFile = file; <END> htmlPanel.setHtmlText(getHtmlText(file)); WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }</code><technical_language>variable named abstractFile exist, prevents pr building</technical_language>

Target:
public void setFile(AbstractFile file) { WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); htmlPanel.setHtmlText(getHtmlText(file)); WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
Source:
<code>public void checkAttributeSyntax(PerunSessionImpl perunSession, String key, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() == null) return; Map<String, String> map = attribute.valueAsMap(); <START> if(map.isEmpty()) return; <END> Set<String> mapKeys = map.keySet(); for(String mapKey: mapKeys) { if(mapKey == null) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can't be null."); Matcher keyMatcher = keyPattern.matcher(mapKey); if(!keyMatcher.matches()) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can be only in format 'Rx', 'Gx', 'Dx' where 'x' is positive integer."); String value = map.get(mapKey); if(value == null) throw new WrongAttributeValueException(attribute, key, "Value in usedGids can't be null."); Matcher valueMatcher = valuePattern.matcher(value); if(!valueMatcher.matches()) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can be only positive integer."); } for(String mapKey: mapKeys) { if(mapKey.startsWith("D")) continue; String value = map.get(mapKey); if(map.containsKey("D" + value)) throw new WrongAttributeValueException(attribute, key, "This gid can't be depleted and used at the same time!"); } }</code><technical_language>This removed</technical_language>

Target:
public void checkAttributeSyntax(PerunSessionImpl perunSession, String key, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() == null) return; Map<String, String> map = attribute.valueAsMap(); Set<String> mapKeys = map.keySet(); for(String mapKey: mapKeys) { if(mapKey == null) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can't be null."); Matcher keyMatcher = keyPattern.matcher(mapKey); if(!keyMatcher.matches()) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can be only in format 'Rx', 'Gx', 'Dx' where 'x' is positive integer."); String value = map.get(mapKey); if(value == null) throw new WrongAttributeValueException(attribute, key, "Value in usedGids can't be null."); Matcher valueMatcher = valuePattern.matcher(value); if(!valueMatcher.matches()) throw new WrongAttributeValueException(attribute, key, "Key in usedGids can be only positive integer."); } for(String mapKey: mapKeys) { if(mapKey.startsWith("D")) continue; String value = map.get(mapKey); if(map.containsKey("D" + value)) throw new WrongAttributeValueException(attribute, key, "This gid can't be depleted and used at the same time!"); } }
Source:
<code>private void purgeMediaToPostAssociationsIfNotInPostAnymore() { ArrayList<MediaModel> allMedia = new ArrayList<>(); Set<MediaModel> failedMedia = mUploadStore.getFailedMediaForPost(mPost); Set<MediaModel> completedMedia = mUploadStore.getCompletedMediaForPost(mPost); Set<MediaModel> uploadingMedia = mUploadStore.getUploadingMediaForPost(mPost); allMedia.addAll(failedMedia); allMedia.addAll(completedMedia); allMedia.addAll(uploadingMedia); <START> if (allMedia != null && !allMedia.isEmpty()) { <END> HashSet<MediaModel> mediaToDeleteAssociationFor = new HashSet<>(); for (MediaModel media : allMedia) { if (!AztecEditorFragment.isMediaInPostBody(this, mPost.getContent(), String.valueOf(media.getId()))) { mediaToDeleteAssociationFor.add(media); } } if (!mediaToDeleteAssociationFor.isEmpty()) { UploadStore.ClearMediaPayload clearMediaPayload = new UploadStore.ClearMediaPayload(mPost, mediaToDeleteAssociationFor); mDispatcher.dispatch(UploadActionBuilder.newClearMediaForPostAction(clearMediaPayload)); } } }</code><technical_language>Niptick - allMedia null here</technical_language>

Target:
private void purgeMediaToPostAssociationsIfNotInPostAnymore() { ArrayList<MediaModel> allMedia = new ArrayList<>(); allMedia.addAll(mUploadStore.getFailedMediaForPost(mPost)); allMedia.addAll(mUploadStore.getCompletedMediaForPost(mPost)); allMedia.addAll(mUploadStore.getUploadingMediaForPost(mPost)); if (!allMedia.isEmpty()) { HashSet<MediaModel> mediaToDeleteAssociationFor = new HashSet<>(); for (MediaModel media : allMedia) { if (!AztecEditorFragment.isMediaInPostBody(this, mPost.getContent(), String.valueOf(media.getId()))) { mediaToDeleteAssociationFor.add(media); } } if (!mediaToDeleteAssociationFor.isEmpty()) { UploadStore.ClearMediaPayload clearMediaPayload = new UploadStore.ClearMediaPayload(mPost, mediaToDeleteAssociationFor); mDispatcher.dispatch(UploadActionBuilder.newClearMediaForPostAction(clearMediaPayload)); } } }
Source:
<code>public void testFindMappingEntryEmptyExternal() { final Optional<ExternalVnicProfileMapping> actual = underTest.findMappingEntry(NETWORK_NAME, VNIC_PROFILE1_NAME, <START> Arrays.asList(emptySourceMapping)); <END> assertFalse(actual.isPresent()); }</code><technical_language>intellij in this case complaints, singletonList instead, I want disable this analysis check. Backing array ins't ArrayList, wasted memory, optimal. I in proposed (consider fixing enabling static-analysis warning)</technical_language>

Target:
public void testFindMappingEntryEmptyExternal() { final Optional<ExternalVnicProfileMapping> actual = underTest.findMappingEntry(NETWORK_NAME, VNIC_PROFILE1_NAME, singletonList(emptySourceMapping)); assertFalse(actual.isPresent()); }
Source:
<code>public static void main(String[] argv) throws IOException { CommandLineParser parser = new DefaultParser(); CommandLine cmd; try { cmd = parser.parse(OPTIONS, argv, true ); } catch (ParseException e) { return; } String[] args = cmd.getArgs(); InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults()); conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "5s", Source.DEFAULT); CollectInfo shell = new CollectInfo(conf); if (args.length < 2) { <START> printHelp(String.format("Command %s requires at least %s arguments (%s provided)%n", <END> 2, argv.length)); System.exit(-1); } int ret; if (cmd.hasOption(LOCAL_OPTION_NAME)) { System.out.println("Executing collectInfo locally"); ret = shell.collectInfoLocal(cmd); } else { System.out.println("Executing collectInfo on all nodes in the cluster"); ret = shell.collectInfoRemote(cmd); } shell.close(); System.exit(ret); }</code><technical_language>3 formatters in this string I 2 arguments</technical_language>

Target:
public static void main(String[] argv) throws IOException { CommandLineParser parser = new DefaultParser(); CommandLine cmd; try { cmd = parser.parse(OPTIONS, argv, true ); } catch (ParseException e) { return; } String[] args = cmd.getArgs(); InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults()); conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "5s", Source.DEFAULT); CollectInfo shell = new CollectInfo(conf); if (args.length < 2) { printHelp(String.format("Command requires at least %s arguments (%s provided)%n", 2, argv.length)); System.exit(-1); } int ret; if (cmd.hasOption(LOCAL_OPTION_NAME)) { System.out.println("Executing collectInfo locally"); ret = shell.collectInfoLocal(cmd); } else { System.out.println("Executing collectInfo on all nodes in the cluster"); ret = shell.collectInfoRemote(cmd); } shell.close(); System.exit(ret); }
Source:
<code>private void updateFileTrackingInfo() throws IOException { try { File tempFile = new File(tempFilePath); FileWriter fw = new FileWriter(tempFile.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fw); bw.write(fileName + "\n"); bw.close(); } catch (IOException ioe) { <START> throw ioe; <END> } }</code><technical_language>need catch simply rethrow</technical_language>

Target:
private void updateFileTrackingInfo() throws IOException { try (FSDataOutputStream outputStream = fs.create(new Path(tempFilePath, file.getName() + ".txt"))) { outputStream.writeUTF(fileName); } }
Source:
<code>public static void setFont(double size) { currentFont = new Font(currentFont.getFamily(), size); <START> Globals.prefs.putDouble(JabRefPreferences.FONT_SIZE, size); <END> }</code><technical_language>I guess this run compatibility issues similar a preference option</technical_language>

Target:
public static void setFont(double size) { currentFont = new Font(currentFont.getFamily(), size); Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, size); }
Source:
<code>public void testReassemblyWithCorruptPage() throws Exception { <START> DeltaByteArrayWriter writer = new DeltaByteArrayWriter(10, 100, new HeapByteBufferAllocator()); <END> String lastValue = null; for (int i = 0; i < 10; i += 1) { lastValue = str(i); writer.writeBytes(Binary.fromString(lastValue)); } byte[] firstPageBytes = writer.getBytes().toByteArray(); writer.reset(); corruptWriter(writer, lastValue); for (int i = 10; i < 20; i += 1) { writer.writeBytes(Binary.fromString(str(i))); } byte[] corruptPageBytes = writer.getBytes().toByteArray(); DeltaByteArrayReader firstPageReader = new DeltaByteArrayReader(); firstPageReader.initFromPage(10, firstPageBytes, 0); for (int i = 0; i < 10; i += 1) { assertEquals(firstPageReader.readBytes().toStringUsingUTF8(), str(i)); } DeltaByteArrayReader corruptPageReader = new DeltaByteArrayReader(); corruptPageReader.initFromPage(10, corruptPageBytes, 0); try { corruptPageReader.readBytes(); fail("Corrupt page did not throw an exception when read"); } catch (ArrayIndexOutOfBoundsException e) { } DeltaByteArrayReader secondPageReader = new DeltaByteArrayReader(); secondPageReader.initFromPage(10, corruptPageBytes, 0); secondPageReader.setPreviousReader(firstPageReader); for (int i = 10; i < 20; i += 1) { assertEquals(secondPageReader.readBytes().toStringUsingUTF8(), str(i)); } }</code><technical_language>please factor out this line: public DeltaByteArrayWriter newDeltaByteArrayWriter() { return new DeltaByteArrayWriter(10, 100, new HeapByteBufferAllocator()); }</technical_language>

Target:
public void testReassemblyWithCorruptPage() throws Exception { DeltaByteArrayWriter writer = getDeltaByteArrayWriter(); String lastValue = null; for (int i = 0; i < 10; i += 1) { lastValue = str(i); writer.writeBytes(Binary.fromString(lastValue)); } ByteBuffer firstPageBytes = writer.getBytes().toByteBuffer(); writer.reset(); corruptWriter(writer, lastValue); for (int i = 10; i < 20; i += 1) { writer.writeBytes(Binary.fromString(str(i))); } ByteBuffer corruptPageBytes = writer.getBytes().toByteBuffer(); DeltaByteArrayReader firstPageReader = new DeltaByteArrayReader(); firstPageReader.initFromPage(10, firstPageBytes, 0); for (int i = 0; i < 10; i += 1) { assertEquals(firstPageReader.readBytes().toStringUsingUTF8(), str(i)); } DeltaByteArrayReader corruptPageReader = new DeltaByteArrayReader(); corruptPageReader.initFromPage(10, corruptPageBytes, 0); try { corruptPageReader.readBytes(); fail("Corrupt page did not throw an exception when read"); } catch (ArrayIndexOutOfBoundsException e) { } DeltaByteArrayReader secondPageReader = new DeltaByteArrayReader(); secondPageReader.initFromPage(10, corruptPageBytes, 0); secondPageReader.setPreviousReader(firstPageReader); for (int i = 10; i < 20; i += 1) { assertEquals(secondPageReader.readBytes().toStringUsingUTF8(), str(i)); } }
Source:
<code>public boolean isSelected() { <START> if (parent != null) { <END> return parent.isSelected(); } return selected; }</code><technical_language>I modify generated methods. If need set this merge</technical_language>

Target:
public boolean isSelected() { return selected; }
Source:
<code>protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { rsp.setContentType("text/plain"); <START> InputStream in = null; <END> OutputStream out = null; try { if (file == null) { in = getServletContext().getResourceAsStream("/robots.txt"); } else { in = new FileInputStream(file); } out = rsp.getOutputStream(); byte[] buffer = new byte[1024]; int count = 0; while ((count = in.read(buffer)) != -1) { out.write(buffer, 0, count); } } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } }</code><technical_language>prefer nested try/finally blocks: InputStream in = openRobotsTxt(); try { OutputStream out = rsp.getOutputStream(); try { ByteStreams.copy(in, out); } finally { out.close(); } } finally { in.close(); }</technical_language>

Target:
protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { rsp.setContentType("text/plain"); InputStream in = openRobotsFile(); try { OutputStream out = rsp.getOutputStream(); try { ByteStreams.copy(in, out); } finally { out.close(); } } finally { in.close(); } }