auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void service(HttpRequest request, HttpResponse response) throws Exception { BufferedWriter w = response.getWriter(); try { DatabaseClient client = getClient(); <START> try (ResultSet rs = <END> client .singleUse() .executeQuery(Statement.of("SELECT SingerId, AlbumId, AlbumTitle FROM Albums"))) { w.write("Albums:\n"); while (rs.next()) { w.write( String.format( "%d %d %s\n", rs.getLong("SingerId"), rs.getLong("AlbumId"), rs.getString("AlbumTitle"))); } } catch (SpannerException e) { w.write(String.format("Error querying database: %s\n", e.getMessage())); response.setStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, e.getMessage()); } } catch (Throwable t) { LOGGER.log(Level.SEVERE, "Spanner example failed", t); w.write(String.format("Error setting up Spanner: %s\n", t.getMessage())); response.setStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, t.getMessage()); } }</code><technical_language>Nit: results clearer</technical_language>

Target:
public void service(HttpRequest request, HttpResponse response) throws Exception { BufferedWriter writer = response.getWriter(); try { DatabaseClient client = getClient(); try (ResultSet rs = client .singleUse() .executeQuery(Statement.of("SELECT SingerId, AlbumId, AlbumTitle FROM Albums"))) { writer.write("Albums:\n"); while (rs.next()) { writer.write( String.format( "%d %d %s\n", rs.getLong("SingerId"), rs.getLong("AlbumId"), rs.getString("AlbumTitle"))); } } catch (SpannerException e) { writer.write(String.format("Error querying database: %s\n", e.getMessage())); response.setStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, e.getMessage()); } } catch (Throwable t) { LOGGER.log(Level.SEVERE, "Spanner example failed", t); writer.write(String.format("Error setting up Spanner: %s\n", t.getMessage())); response.setStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, t.getMessage()); } }
Source:
<code>private static DetailedLibraryDto asDetailedLibraryDto(DetailedLibrary from) { DetailedLibraryDto dto = new DetailedLibraryDto(); if (from.getLibraryDesign() != null) { dto.setLibraryDesignId(from.getLibraryDesign().getId()); } dto.setLibraryDesignCodeId(from.getLibraryDesignCode().getId()); dto.setPreMigrationId(from.getPreMigrationId()); dto.setArchived(from.getArchived()); dto.setNonStandardAlias(from.hasNonStandardAlias()); if (from.getGroupId() != null) { dto.setGroupId(from.getGroupId()); dto.setEffectiveGroupId(from.getGroupId()); dto.setEffectiveGroupIdSample(from.getAlias()); } else { Optional<DetailedSample> effective = ((DetailedSample) from.getSample()).getEffectiveGroupIdSample(); effective.ifPresent(upstream -> { dto.setEffectiveGroupId(upstream.getGroupId()); dto.setEffectiveGroupIdSample(upstream.getAlias()); }); } if (from.getGroupDescription() != null) { dto.setGroupDescription(from.getGroupDescription()); } if (from.getSample() != null) { dto.setIdentityConsentLevel(getIdentityConsentLevelString((DetailedSample) from.getSample())); <START> if (isDetailedSample(from.getSample())) { <END> DetailedSample detailed = (DetailedSample) from.getSample(); if (detailed.getSubproject() != null) { dto.setSubprojectAlias(detailed.getSubproject().getAlias()); dto.setSubprojectPriority(detailed.getSubproject().getPriority()); } } } return dto; }</code><technical_language>remove this if statement checks in place ensure a DetailedLibrary parented a Plain Sample</technical_language>

Target:
private static DetailedLibraryDto asDetailedLibraryDto(DetailedLibrary from) { DetailedLibraryDto dto = new DetailedLibraryDto(); if (from.getLibraryDesign() != null) { dto.setLibraryDesignId(from.getLibraryDesign().getId()); } dto.setLibraryDesignCodeId(from.getLibraryDesignCode().getId()); dto.setPreMigrationId(from.getPreMigrationId()); dto.setArchived(from.getArchived()); dto.setNonStandardAlias(from.hasNonStandardAlias()); if (from.getGroupId() != null) { dto.setGroupId(from.getGroupId()); dto.setEffectiveGroupId(from.getGroupId()); dto.setEffectiveGroupIdSample(from.getAlias()); } else { Optional<DetailedSample> effective = ((DetailedSample) from.getSample()).getEffectiveGroupIdSample(); effective.ifPresent(upstream -> { dto.setEffectiveGroupId(upstream.getGroupId()); dto.setEffectiveGroupIdSample(upstream.getAlias()); }); } if (from.getGroupDescription() != null) { dto.setGroupDescription(from.getGroupDescription()); } if (from.getSample() != null) { dto.setIdentityConsentLevel(getIdentityConsentLevelString((DetailedSample) from.getSample())); DetailedSample detailed = (DetailedSample) from.getSample(); if (detailed.getSubproject() != null) { dto.setSubprojectAlias(detailed.getSubproject().getAlias()); dto.setSubprojectPriority(detailed.getSubproject().getPriority()); } } return dto; }
Source:
<code>public static TreeWalk forPath(final Repository db, final String path, final AnyObjectId... trees) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { <START> ObjectReader reader = db.newObjectReader(); try { return forPath(reader, path, trees); } finally { reader.close(); } <END> }</code><technical_language>Rewrite try-with-resources: try (ObjectReader reader = db.newObjectReader()) { return forPath(reader, path, trees); }</technical_language>

Target:
public static TreeWalk forPath(final Repository db, final String path, final AnyObjectId... trees) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { try (ObjectReader reader = db.newObjectReader()) { return forPath(reader, path, trees); } }
Source:
<code>public void setConceptsInDbText(String text) { if(text.equals("0")){ downloadConceptsButton.setEnabled(false); <START> Toast.makeText(getActivity(), "There are no concepts in DB!", <END> Toast.LENGTH_LONG).show(); } conceptsInDbTextView.setText(text); }</code><technical_language>store this string in strings.xml</technical_language>

Target:
public void setConceptsInDbText(String text) { if(text.equals("0")){ downloadConceptsButton.setEnabled(false); ToastUtil.showLongToast(getActivity(), ToastUtil.ToastType.WARNING, R.string.settings_no_concepts_toast); } conceptsInDbTextView.setText(text); }
Source:
<code>public static String encryptPassword(String plainPassword, String algorithm) { if (plainPassword == null) { throw new IllegalArgumentException(); } if (algorithm != null) { if (algorithm.equals(ALGORITHM_COMMON_V3)) { try { <START> return CryptoMigrationUtil.encrypt(plainPassword); <END> } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } else if (algorithm.equals(ALGORITHM_COMMON) || algorithm.equals(ALGORITHM_COMMON_V2)) { return null; } } return encryptPasswordBase64(plainPassword); }</code><technical_language>Is correct this class CryptoMigrationUtil instead of StudioEncryption class</technical_language>

Target:
public static String encryptPassword(String plainPassword, String algorithm) { if (plainPassword == null) { throw new IllegalArgumentException(); } if (algorithm != null) { if (algorithm.equals(ALGORITHM_COMMON_V3)) { try { return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM) .encrypt(plainPassword); } catch (Exception e) { LOGGER.error(e.getMessage(), e); return null; } } else if (algorithm.equals(ALGORITHM_COMMON) || algorithm.equals(ALGORITHM_COMMON_V2)) { return null; } } return encryptPasswordBase64(plainPassword); }
Source:
<code>public LoggingHandler(Level level) { <START> setLevel(level); <END> }</code><technical_language>OK, @englishman , good. concerns, critical, follow. is project style. call non-final methods ctors: <LINK_0> quoting: > In general a bad idea call a non-final method a constructor for precisely this reason - subclass constructor body executed yet, effectively calling a method in environment fully initialized. wrong LoggingHandler is in target apps, setLevel() final, especially for maintain version 4.3.x. I guess a private void doSetLevel() overcome issue :smile:</technical_language>

Target:
public LoggingHandler(Level level) { doSetLevel(level); }
Source:
<code>public Response toResponse(WebApplicationException e) { <START> return status(e.getResponse().getStatus()).entity(e.getMessage()).build(); <END> }</code><technical_language>return a json object instead of plain text string? For example json { "error": "<message>" }</technical_language>

Target:
public Response toResponse(WebApplicationException e) { return status(e.getResponse().getStatus()).entity(new ErrorResponse(e.getMessage())).build(); }
Source:
<code>private LineString getBuildingFeatureOutline(@NonNull Style style) { final PointF pixel = mapboxMap.getProjection().toScreenLocation(new LatLng( mapboxMap.getCameraPosition().target.getLatitude(), mapboxMap.getCameraPosition().target.getLongitude() )); List<Point> pointList = new ArrayList<>(); if (style.getLayer("building") != null) { List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, "building"); if (features.size() > 0) { Feature buildingFeature = features.get(0); if (buildingFeature.geometry() instanceof Polygon) { <START> for (int i = 0; i < ((Polygon) buildingFeature.geometry()).coordinates().size(); i++) { <END> for (int j = 0; j < ((Polygon) buildingFeature.geometry()).coordinates().get(i).size(); j++) { pointList.add(Point.fromLngLat( ((Polygon) buildingFeature.geometry()).coordinates().get(i).get(j).longitude(), ((Polygon) buildingFeature.geometry()).coordinates().get(i).get(j).latitude() )); } } } } } return LineString.fromLngLats(pointList); }</code><technical_language>NIT: assign buildingFeature a local Polygon type variable clean of casts</technical_language>

Target:
private LineString getBuildingFeatureOutline(@NonNull Style style) { final PointF pixel = mapboxMap.getProjection().toScreenLocation(new LatLng( mapboxMap.getCameraPosition().target.getLatitude(), mapboxMap.getCameraPosition().target.getLongitude() )); List<Point> pointList = new ArrayList<>(); if (style.getLayer("building") != null) { List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, "building"); if (features.size() > 0) { if (features.get(0).geometry() instanceof Polygon) { Polygon buildingFeature = (Polygon) features.get(0).geometry(); for (int i = 0; i < buildingFeature.coordinates().size(); i++) { for (int j = 0; j < buildingFeature.coordinates().get(i).size(); j++) { pointList.add(Point.fromLngLat( buildingFeature.coordinates().get(i).get(j).longitude(), buildingFeature.coordinates().get(i).get(j).latitude() )); } } } } } else { Toast.makeText(this, R.string.building_layer_not_present, Toast.LENGTH_SHORT).show(); } return LineString.fromLngLats(pointList); }
Source:
<code>public void testDoNotUpgradePropSet() throws Exception { String tableName = "HBASE_SYNTH_TEST"; startMiniClusterWithToggleNamespaceMapping(Boolean.FALSE.toString()); Properties propsDoNotUpgradePropSet = new Properties(); <START> Connection con1 = DriverManager.getConnection(getJdbcUrl(),propsDoNotUpgradePropSet); <END> String ddl = "CREATE TABLE "+ tableName +" (PK1 VARCHAR not null, PK2 VARCHAR not null, " + "COL1 varchar, COL2 varchar " + "CONSTRAINT pk PRIMARY KEY(PK1,PK2))"; con1.createStatement().execute(ddl); con1.createStatement().execute("UPSERT INTO " + tableName + " values ('pk1','pk2','c1','c2')"); con1.commit(); testUtil.getMiniHBaseCluster().getMaster().stopMaster(); UpgradeUtil.doNotUpgradeOnFirstConnection(propsDoNotUpgradePropSet); Connection con2 = DriverManager.getConnection(getJdbcUrl(),propsDoNotUpgradePropSet); ResultSet rs = con2.createStatement().executeQuery("select * from " + tableName); assertTrue(rs.next()); assertEquals("pk1", rs.getString(1)); assertEquals("pk2", rs.getString(2)); assertFalse(rs.next()); con1.close(); con2.close(); }</code><technical_language>nit: try-with-resources for conn stmt</technical_language>

Target:
public void testDoNotUpgradePropSet() throws Exception { String tableName = "HBASE_SYNTH_TEST"; startMiniClusterWithToggleNamespaceMapping(Boolean.FALSE.toString()); Properties propsDoNotUpgradePropSet = new Properties(); try (Connection con1 = DriverManager.getConnection(getJdbcUrl(), propsDoNotUpgradePropSet)) { String ddl = "CREATE TABLE " + tableName + " (PK1 VARCHAR not null, " + "PK2 VARCHAR not null, COL1 varchar, COL2 varchar " + "CONSTRAINT pk PRIMARY KEY(PK1,PK2))"; con1.createStatement().execute(ddl); con1.createStatement().execute( "UPSERT INTO " + tableName + " values ('pk1','pk2','c1','c2')"); con1.commit(); testUtil.getMiniHBaseCluster().getMaster().stopMaster(); UpgradeUtil.doNotUpgradeOnFirstConnection(propsDoNotUpgradePropSet); try (Connection con2 = DriverManager.getConnection(getJdbcUrl(), propsDoNotUpgradePropSet)) { ResultSet rs = con2.createStatement().executeQuery("select * from " + tableName); assertTrue(rs.next()); assertEquals("pk1", rs.getString(1)); assertEquals("pk2", rs.getString(2)); assertFalse(rs.next()); } } finally { testUtil.getMiniHBaseCluster().startMaster(); } }
Source:
<code><START> public ServiceBusManagementClientBuilder clientOptions(ClientOptions clientOptions) { <END> this.clientOptions = clientOptions; return this; }</code><technical_language>return type ServiceBusAdministrationClientBuilder</technical_language>

Target:
public ServiceBusAdministrationClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; }
Source:
<code>File writeBam(final SAMRecordSetBuilder builder, final File f) { <START> final SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(builder.getHeader(), false, f); <END> builder.forEach(out::addAlignment); out.close(); return f; }</code><technical_language>try-with-resources</technical_language>

Target:
File writeBam(final SAMRecordSetBuilder builder, final File f) { try (final SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(builder.getHeader(), false, f)) { builder.forEach(out::addAlignment); } return f; }
Source:
<code>public void printText(String text) { view.print(text, false); <START> Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { <END> @Override public void execute() { view.scrollBottom(); } }); }</code><technical_language>nice if left a short explanation deferred command</technical_language>

Target:
public void printText(String text) { view.print(text, false); view.scrollBottom(); }
Source:
<code>public synchronized ClassSpec getClassSpec(final String fileName) throws IOException { final JarEntry entry = getJarEntry(fileName); if (entry == null) { return null; } <START> final ClassSpec spec = new ClassSpec(); <END> final long size = entry.getSize(); if (size == -1) { spec.setBytes(getClassBytes(entry)); CodeSource codeSource = createCodeSource(entry); spec.setCodeSource(codeSource); return spec; } else if (size <= (long) Integer.MAX_VALUE) { spec.setBytes(getClassBytes(entry, (int) size)); CodeSource codeSource = createCodeSource(entry); spec.setCodeSource(codeSource); return spec; } else { throw new IOException("Resource is too large to be a valid class file"); } }</code><technical_language>this a separate step is necessary do a diff -w flag, (in GitHub) add ?w=1 query parameters, view diff whitespace changes</technical_language>

Target:
public synchronized ClassSpec getClassSpec(final String fileName) throws IOException { final JarEntry entry = getJarEntry(fileName); if (entry == null) { return null; } final ClassSpec spec = new ClassSpec(); final long size = entry.getSize(); if (size == -1) { spec.setBytes(getClassBytes(entry)); spec.setCodeSource(createCodeSource(entry)); } else if (size <= (long) Integer.MAX_VALUE) { spec.setBytes(getClassBytes(entry, (int) size)); spec.setCodeSource(createCodeSource(entry)); } else { throw new IOException("Resource is too large to be a valid class file"); } return spec; }
Source:
<code>public void processConnectionEvent(Message message, int state) { stateLogD("processConnectionEvent, state=" + state); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: stateLogW("ignore DISCONNECTED event"); break; case HeadsetHalConstants.CONNECTION_STATE_CONNECTED: case HeadsetHalConstants.CONNECTION_STATE_CONNECTING: if (mHeadsetService.okToAcceptConnection(mDevice)) { stateLogI("accept incoming connection"); transitionTo(mConnecting); } else { stateLogI("rejected incoming HF, <START> priority=" <END> + mHeadsetService.getConnectionPolicy(mDevice) + " bondState=" + mAdapterService.getBondState(mDevice)); if (!mNativeInterface.disconnectHfp(mDevice)) { stateLogE("failed to disconnect"); } broadcastConnectionState(mDevice, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_DISCONNECTED); } break; case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING: stateLogW("Ignore DISCONNECTING event"); break; default: stateLogE("Incorrect state: " + state); break; } }</code><technical_language>nit: update</technical_language>

Target:
public void processConnectionEvent(Message message, int state) { stateLogD("processConnectionEvent, state=" + state); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: stateLogW("ignore DISCONNECTED event"); break; case HeadsetHalConstants.CONNECTION_STATE_CONNECTED: case HeadsetHalConstants.CONNECTION_STATE_CONNECTING: if (mHeadsetService.okToAcceptConnection(mDevice)) { stateLogI("accept incoming connection"); transitionTo(mConnecting); } else { stateLogI("rejected incoming HF, connectionPolicy=" + mHeadsetService.getConnectionPolicy(mDevice) + " bondState=" + mAdapterService.getBondState(mDevice)); if (!mNativeInterface.disconnectHfp(mDevice)) { stateLogE("failed to disconnect"); } broadcastConnectionState(mDevice, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_DISCONNECTED); } break; case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING: stateLogW("Ignore DISCONNECTING event"); break; default: stateLogE("Incorrect state: " + state); break; } }
Source:
<code>@Override public List<Pair<RelTraitSet, List<RelTraitSet>>> deriveCollation(RelTraitSet nodeTraits, List<RelTraitSet> inputTraits) { RelTraitSet left = inputTraits.get(0), right = inputTraits.get(1); RelCollation leftCollation = TraitUtils.collation(left), rightCollation = TraitUtils.collation(right); if (!isPrefix(rightCollation.getKeys(), joinInfo.rightKeys)) return ImmutableList.of(); if (variablesSet.size() == 1) nodeTraits.replace(leftCollation); else nodeTraits.replace(RelCollations.EMPTY); return ImmutableList.of( Pair.of( nodeTraits.replace(leftCollation), ImmutableList.of( left, <START> right.replace(rightCollation) <END> ) ) ); }</code><technical_language>this replacement (for right hand) is unnecessary</technical_language>

Target:
@Override public List<Pair<RelTraitSet, List<RelTraitSet>>> deriveCollation( RelTraitSet nodeTraits, List<RelTraitSet> inputTraits ) { RelTraitSet left = inputTraits.get(0), right = inputTraits.get(1); RelCollation leftCollation = TraitUtils.collation(left), rightCollation = TraitUtils.collation(right); List<Integer> newRightCollationFields = maxPrefix(rightCollation.getKeys(), joinInfo.leftKeys); if (F.isEmpty(newRightCollationFields)) return ImmutableList.of(); if (variablesSet.size() == 1) nodeTraits.replace(leftCollation); else nodeTraits.replace(RelCollations.EMPTY); return ImmutableList.of( Pair.of( nodeTraits.replace(leftCollation), ImmutableList.of( left, right ) ) ); }
Source:
<code>static DurationValue durationBetween( Temporal from, Temporal to ) { long months = 0; long days = 0; if ( from.isSupported( EPOCH_DAY ) && to.isSupported( EPOCH_DAY ) ) { LocalDate fromDate; LocalDate toDate; try { fromDate = LocalDate.from( from ); toDate = LocalDate.from( to ); } catch ( DateTimeException e ) { throw new InvalidTemporalArgumentException( e.getMessage(), e ); } Period period = Period.between( fromDate, toDate ); months = period.getYears() * 12L + period.getMonths(); days = period.getDays(); if ( months != 0 || days != 0 ) { try { <START> from = from.plus( period ); <END> } catch ( DateTimeException | ArithmeticException e ) { throw new TemporalArithmeticException( e.getMessage(), e ); } } } long nanos = assertValidUntil( from, to, NANOS ); return newDuration( months, days, nanos / NANOS_PER_SECOND, (int) (nanos % NANOS_PER_SECOND) ); }</code><technical_language>Is this try catch equivalent assertValidArithmetic</technical_language>

Target:
static DurationValue durationBetween( Temporal from, Temporal to ) { long months = 0; long days = 0; if ( from.isSupported( EPOCH_DAY ) && to.isSupported( EPOCH_DAY ) ) { LocalDate fromDate; LocalDate toDate; try { fromDate = LocalDate.from( from ); toDate = LocalDate.from( to ); } catch ( DateTimeException e ) { throw new InvalidValuesArgumentException( e.getMessage(), e ); } Period period = Period.between( fromDate, toDate ); months = period.getYears() * 12L + period.getMonths(); days = period.getDays(); if ( months != 0 || days != 0 ) { try { from = from.plus( period ); } catch ( DateTimeException | ArithmeticException e ) { throw new TemporalArithmeticException( e.getMessage(), e ); } } } long nanos = assertValidUntil( from, to, NANOS ); return newDuration( months, days, nanos / NANOS_PER_SECOND, (int) (nanos % NANOS_PER_SECOND) ); }
Source:
<code>@Test public void headWithSiblings() throws Exception { final String bucket = UUID.randomUUID().toString(); final String key = "k"; final String value = "v"; final String value2 = "v2"; IRiakObject o = RiakObjectBuilder.newBuilder(bucket, key).withValue(value).build(); IRiakObject o2 = RiakObjectBuilder.newBuilder(bucket, key).withValue(value2).build(); client.updateBucket(bucket, new BucketPropertiesBuilder().allowSiblings(true).build()); Thread.sleep(500); client.store(o); client.store(o2); RiakResponse r = client.fetch(bucket, key); assertNotNull(r); assertTrue(r.hasValue()); assertTrue(r.hasSiblings()); assertEquals(2, r.getRiakObjects().length); RiakResponse headResponse = client.head(bucket, key, null); assertNotNull(headResponse); assertTrue(headResponse.hasValue()); assertTrue(headResponse.hasSiblings()); <START> for (IRiakObject iro : headResponse.getRiakObjects()) { <END> if (client.getTransport() != Transport.HTTP) { assertEmptyString(iro.getValueAsString()); } } }</code><technical_language>I thought in cases siblings encountered fetched full objects I guess not. is done for transport other</technical_language>

Target:
@Test public void headWithSiblings() throws Exception { final String bucket = UUID.randomUUID().toString(); final String key = "k"; final String value = "v"; final String value2 = "v2"; IRiakObject o = RiakObjectBuilder.newBuilder(bucket, key).withValue(value).build(); IRiakObject o2 = RiakObjectBuilder.newBuilder(bucket, key).withValue(value2).build(); client.updateBucket(bucket, new BucketPropertiesBuilder().allowSiblings(true).build()); Thread.sleep(500); client.store(o); client.store(o2); RiakResponse r = client.fetch(bucket, key); assertNotNull(r); assertTrue(r.hasValue()); assertTrue(r.hasSiblings()); assertEquals(2, r.getRiakObjects().length); RiakResponse headResponse = client.head(bucket, key, null); assertNotNull(headResponse); assertTrue(headResponse.hasValue()); assertTrue(headResponse.hasSiblings()); for (IRiakObject iro : headResponse.getRiakObjects()) { assertNotEmptyString(iro.getValueAsString()); } }
Source:
<code>private int createNotification(Context context, NotificationData data) { initNotificationManager(context); PendingIntent doesNothingPendingIntent = PendingIntent.getActivity(context, -1, new Intent(), PendingIntent.FLAG_ONE_SHOT); <START> Notification.Builder notificationBuilder; <END> if (android.os.Build.VERSION.SDK_INT < 26) { notificationBuilder = new Notification.Builder(context); } else { notificationBuilder = new Notification.Builder(context, CHANNEL_ID); } notificationBuilder.setContentTitle(data.getNotificationTitleWorking()) .setContentText(data.getNotificationTextWorking()).setSmallIcon(data.getNotificationIcon()) .setOngoing(true).setContentIntent(doesNothingPendingIntent); data.setNotificationBuilder(notificationBuilder); notificationDataMap.put(notificationId, data); return notificationId++; }</code><technical_language><LINK_0> avoid build version tests</technical_language>

Target:
private int createNotification(Context context, NotificationData data) { initNotificationManager(context); PendingIntent doesNothingPendingIntent = PendingIntent.getActivity(context, -1, new Intent(), PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID); notificationBuilder.setContentTitle(data.getNotificationTitleWorking()) .setContentText(data.getNotificationTextWorking()) .setSmallIcon(data.getNotificationIcon()) .setOngoing(true) .setContentIntent(doesNothingPendingIntent); data.setNotificationBuilder(notificationBuilder); notificationDataMap.put(notificationId, data); return notificationId++; }
Source:
<code>public boolean isCounting() { assert startTime != -1; <START> return System.currentTimeMillis() - startTime <= duration.toMillis(); <END> }</code><technical_language>sense change this comparison relevant Duration method well? provide us, prevent regressions later</technical_language>

Target:
public boolean isCounting() { assert startTime != null; Duration elapsed = Duration.between(startTime, Instant.now()); return elapsed.compareTo(duration) <= 0; }
Source:
<code>public void makeDiscoverablePatchForbiddenTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build(); Item item = ItemBuilder.createItem(context, col1) .withTitle("Public item 1") .withIssueDate("2017-10-17") .withAuthor("Smith, Donald").withAuthor("Doe, John") .withSubject("ExtraEntry") .makeUnDiscoverable() .build(); String token = getAuthToken(eperson.getEmail(), password); String tokenAdmin = getAuthToken(admin.getEmail(), password); List<Operation> ops = new ArrayList<Operation>(); <START> ReplaceOperation replaceOperation = new ReplaceOperation("/discoverable", "true"); <END> ops.add(replaceOperation); String patchBody = getPatchContent(ops); getClient(token).perform(patch("/api/core/items/" + item.getID()) .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isForbidden()); getClient(tokenAdmin).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString()))) .andExpect(jsonPath("$.discoverable", Matchers.is(false))); }</code><technical_language>official true instead "true"</technical_language>

Target:
public void makeDiscoverablePatchForbiddenTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build(); Item item = ItemBuilder.createItem(context, col1) .withTitle("Public item 1") .withIssueDate("2017-10-17") .withAuthor("Smith, Donald").withAuthor("Doe, John") .withSubject("ExtraEntry") .makeUnDiscoverable() .build(); String token = getAuthToken(eperson.getEmail(), password); String tokenAdmin = getAuthToken(admin.getEmail(), password); List<Operation> ops = new ArrayList<Operation>(); ReplaceOperation replaceOperation = new ReplaceOperation("/discoverable", true); ops.add(replaceOperation); String patchBody = getPatchContent(ops); getClient(token).perform(patch("/api/core/items/" + item.getID()) .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isForbidden()); getClient(tokenAdmin).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString()))) .andExpect(jsonPath("$.discoverable", Matchers.is(false))); }
Source:
<code>public ConfigurationScopeAwareProvider(Configuration configuration) { <START> this.configuration = requireNonNull(configuration); <END> }</code><technical_language>exception/message thrown this call? Assert#nonNull(T, Supplier<String>) function contained in framework. return field requireNonNull() though. :/</technical_language>

Target:
public ConfigurationScopeAwareProvider(Configuration configuration) { this.configuration = Assert.nonNull(configuration, () -> "configuration may not be null"); }
Source:
<code>private void openButtonAction(ActionEvent e) { progressDialog = new ProgressDialog(root, graphLoadService); <START> Optional<ButtonType> result = new OpenDialog(root, Alert.AlertType.NONE, graphLoadService, <END> newickLoadService).showAndWait(); if (result.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { restart(); } else { reset(); } }</code><technical_language>Is necessary pass AlertType OpenDialog</technical_language>

Target:
private void openButtonAction(ActionEvent e) { progressDialog = new ProgressDialog(root, graphLoadService); Optional<ButtonType> result = new OpenDialog(root, graphLoadService, newickLoadService) .showAndWait(); if (result.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { restart(); } else { reset(); } }
Source:
<code>public Array<Actor> getExtras() { <START> final Array<Actor> actors = new Array<Actor>(false, 2); <END> actors.add(this.paint); actors.add(this.eraser); return actors; }</code><technical_language>Unnecessary final</technical_language>

Target:
public Array<Actor> getExtras() { Array<Actor> actors = new Array<Actor>(false, 2); actors.add(this.paint); actors.add(this.eraser); return actors; }
Source:
<code>public void testResolvingNonNativeNullHandlingOrderIsUnsupported() { KeyValueQuery<String> keyValueQuery = new KeyValueQuery<String>("^pg~]=P"); Sort.Order[] sortOrderArray = new Sort.Order[7]; Sort.Order sortOrderA = Sort.Order.asc("^pg~]=P"); sortOrderArray[0] = sortOrderA; Sort.Order sortOrderB = sortOrderA.nullsLast(); sortOrderArray[1] = sortOrderB; Sort sort = Sort.by(sortOrderArray); keyValueQuery.setSort(sort); HazelcastSortAccessor hazelcastSortAccessor = new HazelcastSortAccessor(); hazelcastSortAccessor.resolve(keyValueQuery); <START> fail("Should have thrown UnsupportedOperationException"); <END> }</code><technical_language>This is care annotation. test fails message UnsupportedOperationException expected</technical_language>

Target:
public void testResolvingNonNativeNullHandlingOrderIsUnsupported() { KeyValueQuery<String> keyValueQuery = new KeyValueQuery<>("^pg~]=P"); Sort.Order sortOrder1 = Sort.Order.asc("^pg~]=P"); Sort.Order sortOrder2 = sortOrder1.nullsLast(); keyValueQuery.setSort(Sort.by(sortOrder1, sortOrder2)); HazelcastSortAccessor hazelcastSortAccessor = new HazelcastSortAccessor(); hazelcastSortAccessor.resolve(keyValueQuery); }
Source:
<code>public DataSize getUserMemoryReservation() { <START> return succinctBytes(0); <END> }</code><technical_language>new DataSize(0, BYTE) instead... DataSize (and Duration) a constant for this</technical_language>

Target:
public DataSize getUserMemoryReservation() { return new DataSize(0, BYTE); }
Source:
<code>public boolean removeAll(Collection<?> c) { for (XWikiAttachment x : (Collection<? extends XWikiAttachment>) c) { <START> if (this.list.contains(x)) <END> remove(x); } return true; }</code><technical_language>Missing follow XWiki codestyle</technical_language>

Target:
public boolean removeAll(Collection<?> c) { boolean changed = false; for (XWikiAttachment x : (Collection<? extends XWikiAttachment>) c) { if (map.get(x.getFilename()) == x) { map.remove(x.getFilename()); changed = true; } } if (changed) { updatedMap(); } return changed; }
Source:
<code>protected List<T> fromString(String s) { <START> final String escapedString = escaper.escape(s); <END> final String[] elements = escapedString.split(elementDelimiterPattern); final List<T> result = newArrayList(); for (String element : elements) { checkElement(element); final T convertedValue = Stringifiers.convert(unquote(element), listGenericClass); result.add(convertedValue); } return result; }</code><technical_language>above, Guava's Splitter instead of Joiner extending QuotedListItem produce object of T a method called T parse(String). In this knowledge of quoting QuotedListIem only</technical_language>

Target:
protected List<T> fromString(String s) { final String escapedString = escaper.escape(s); final List<String> items = newArrayList(splitter.split(escapedString)); final Converter<String, String> quoteConverter = ItemQuoter.converter(); final List<T> result = newArrayList(); for (String item : items) { final T convertedItem = quoteConverter.reverse() .andThen(elementStringifier.reverse()) .convert(item); result.add(convertedItem); } return result; }
Source:
<code>public void visit( TypeDefinitionLink n ) { TypeDefinition linkedType = null; if( n.linkedTypeName().equals( TypeDefinitionUndefined.UNDEFINED_KEYWORD ) ) { linkedType = TypeDefinitionUndefined.getInstance(); } else { Optional< SymbolInfo > targetSymbolInfo = getSymbol( n.context(), n.linkedTypeName() ); if( !targetSymbolInfo.isPresent() ) { error( buildSymbolNotFoundError( n, n.id() ) ); return; } if( !(targetSymbolInfo.get().node() instanceof TypeDefinition) ) { error( buildSymbolTypeMismatchError( n, n.id(), "TypeDefinition", targetSymbolInfo.get().node().getClass().getSimpleName() ) ); return; } linkedType = (TypeDefinition) targetSymbolInfo.get().node(); <START> while( linkedType instanceof TypeDefinitionLink ) { <END> linkedType = ((TypeDefinitionLink) linkedType).linkedType(); } if( linkedType.equals( n ) ) { error( buildSymbolNotFoundError( n, n.id() ) ); return; } } n.setLinkedType( linkedType ); }</code><technical_language>risk this loops infinitely in cases following? If so, fix this putting upper bound (100?). type A:B type B:A</technical_language>

Target:
public void visit( TypeDefinitionLink n ) { TypeDefinition linkedType = null; if( n.linkedTypeName().equals( TypeDefinitionUndefined.UNDEFINED_KEYWORD ) ) { linkedType = TypeDefinitionUndefined.getInstance(); } else { Optional< SymbolInfo > targetSymbolInfo = getSymbol( n.context(), n.linkedTypeName() ); if( !targetSymbolInfo.isPresent() ) { error( buildSymbolNotFoundError( n, n.id() ) ); return; } if( !(targetSymbolInfo.get().node() instanceof TypeDefinition) ) { error( buildSymbolTypeMismatchError( n, n.id(), "TypeDefinition", targetSymbolInfo.get().node().getClass().getSimpleName() ) ); return; } linkedType = (TypeDefinition) targetSymbolInfo.get().node(); int linkCounter = 0; while( linkedType instanceof TypeDefinitionLink ) { if( linkCounter == 100 ) { error( buildTypeLinkOutOfBoundError( n ) ); return; } linkedType = ((TypeDefinitionLink) linkedType).linkedType(); linkCounter++; } if( linkedType.equals( n ) ) { error( buildSymbolNotFoundError( n, n.id() ) ); return; } } n.setLinkedType( linkedType ); }
Source:
<code>public static boolean isSkipCommitNetworkChangesSupported(VDS <START> vds) { <END> return Version.v4_3.lessOrEquals(vds.getSupportedClusterVersionsSet()) && Version.v4_4.lessOrEquals(Version.ALL); }</code><technical_language>Please handle vds == null call this method in a ensure vds != null. this more explicit requireNonNull NotNull</technical_language>

Target:
public static boolean isSkipCommitNetworkChangesSupported(VDS vds) { return vds != null && Version.v4_3.lessOrEquals(vds.getSupportedClusterVersionsSet()); }
Source:
<code>protected boolean canDoAction() { if (!isVmExist() || !acquireLockInternal()) { return false; } VM vm = getVm(); if (vm != null) { if (!canRunActionOnNonManagedVm()) { return false; } updateDisksFromDb(); if (!isDiskCanBeAddedToVm(getParameters().getDiskInfo(), vm) || !isDiskPassPciAndIdeLimit(getParameters().getDiskInfo())) { return false; } } <START> else { <END> if (getParameters().getPlugDiskToVm()) { return failCanDoAction(VdcBllMessages.CANNOT_ADD_FLOATING_DISK_WITH_PLUG_VM_SET); } } if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfImageDiskCanBeAdded(vm); } if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfLunDiskCanBeAdded(); } return true; }</code><technical_language>} else ...</technical_language>

Target:
protected boolean canDoAction() { if (!isVmExist() || !acquireLockInternal()) { return false; } VM vm = getVm(); if (vm != null) { if (!canRunActionOnNonManagedVm()) { return false; } updateDisksFromDb(); if (!isDiskCanBeAddedToVm(getParameters().getDiskInfo(), vm) || !isDiskPassPciAndIdeLimit(getParameters().getDiskInfo())) { return false; } } else if (Boolean.TRUE.equals(getParameters().getPlugDiskToVm())) { return failCanDoAction(VdcBllMessages.CANNOT_ADD_FLOATING_DISK_WITH_PLUG_VM_SET); } if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfImageDiskCanBeAdded(vm); } if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfLunDiskCanBeAdded(); } return true; }
Source:
<code>public void onError(Throwable e) { Log.e(TAG, e.getMessage()); loginError.setValue(e); if (url.get() != null && url.get().contains("https")) <START> testConnection(true, URLHelper.INSTANCE.getUrlWithMethod(url.get(), "http")); <END> else if (url.get().contains("http")) url.set(url.get().replaceAll("http://", "")); }</code><technical_language>I fully catch this code. is intention here</technical_language>

Target:
public void onError(Throwable e) { Log.e(TAG, e.getMessage()); loginError.setValue(e); if (testedUrl != null && testedUrl.contains("https")) testConnection(true, URLHelper.INSTANCE.getUrlWithMethod(url.get(), "http")); }
Source:
<code>public void updateConnection(@QueryParam("token") String authToken, @PathParam("connectionID") String connectionID, APIConnection connection) throws GuacamoleException { UserContext userContext = authenticationService.getUserContext(authToken); if (connection == null) throw new GuacamoleClientException("Connection JSON must be submitted when updating connections."); ConnectionGroup rootGroup = userContext.getRootConnectionGroup(); Directory<String, Connection> connectionDirectory = rootGroup.getConnectionDirectory(); Connection existingConnection = connectionDirectory.get(connectionID); if (existingConnection == null) throw new GuacamoleResourceNotFoundException("No such connection: \"" + connectionID + "\""); <START> Connection wrappedConnection = new APIConnectionWrapper(connection); <END> existingConnection.setConfiguration(wrappedConnection.getConfiguration()); existingConnection.setName(wrappedConnection.getName()); connectionDirectory.update(existingConnection); }</code><technical_language>Do need do this wrapping here</technical_language>

Target:
public void updateConnection(@QueryParam("token") String authToken, @PathParam("connectionID") String connectionID, APIConnection connection) throws GuacamoleException { UserContext userContext = authenticationService.getUserContext(authToken); if (connection == null) throw new GuacamoleClientException("Connection JSON must be submitted when updating connections."); ConnectionGroup rootGroup = userContext.getRootConnectionGroup(); Directory<String, Connection> connectionDirectory = rootGroup.getConnectionDirectory(); Connection existingConnection = connectionDirectory.get(connectionID); if (existingConnection == null) throw new GuacamoleResourceNotFoundException("No such connection: \"" + connectionID + "\""); GuacamoleConfiguration config = new GuacamoleConfiguration(); config.setProtocol(connection.getProtocol()); config.setParameters(connection.getParameters()); existingConnection.setConfiguration(config); existingConnection.setName(connection.getName()); connectionDirectory.update(existingConnection); }
Source:
<code>public Checkpoint(String checkpoint) { checkNotNull(checkpoint, "checkpoint may not be null"); logger.info("Checkpoint: '" + checkpoint + "'"); Object[] objs; try { if (checkpoint.indexOf(';') < 0) { objs = SHORT_FORMAT.parse(checkpoint); } else { objs = FULL_FORMAT.parse(checkpoint); } } catch (ParseException e) { throw new IllegalArgumentException( "Invalid Checkpoint: " + checkpoint, e); } switch (objs.length) { case 3: <START> timestamp = (Date) objs[1]; <END> guid = new Id((String) objs[2]); case 1: type = (String) objs[0]; break; default: throw new IllegalArgumentException( "Invalid Checkpoint: " + checkpoint); } }</code><technical_language>I understand parse a Date out of strings, need a special getter get want. want objects, strings. v3 Checkpoint in strings <Date, Id> pairs, stored <String, String> pairs. better</technical_language>

Target:
public Checkpoint(String checkpoint) { checkNotNull(checkpoint, "checkpoint may not be null"); logger.info("Checkpoint: '" + checkpoint + "'"); try { if (checkpoint.indexOf(';') < 0) { Object[] objs = SHORT_FORMAT.parse(checkpoint); type = (String) objs[0]; timestamp = null; guid = null; } else { Object[] objs = FULL_FORMAT.parse(checkpoint); type = (String) objs[0]; timestamp = (String) objs[1]; guid = (String) objs[2]; } } catch (ParseException e) { throw new IllegalArgumentException( "Invalid Checkpoint: " + checkpoint, e); } }
Source:
<code>private LeaderLatch createNewLeaderLatch() { final LeaderLatch newLeaderLatch = new LeaderLatch( curator, latchPath, self.getHostAndPortToUse() ); newLeaderLatch.addListener( new LeaderLatchListener() { @Override public void isLeader() { try { if (leader) { log.warn("I'm being asked to become leader. But I am already the leader. Ignored event."); return; } leader = true; <START> term++; <END> listener.becomeLeader(); } catch (Exception ex) { log.makeAlert(ex, "listener becomeLeader() failed. Unable to become leader").emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); CloseQuietly.close(oldLatch); leader = false; try { Thread.sleep(1000); leaderLatch.get().start(); } catch (Exception e) { log.makeAlert(e, "I am a zombie").emit(); } } } @Override public void notLeader() { try { if (!leader) { log.warn("I'm being asked to stop being leader. But I am not the leader. Ignored event."); return; } leader = false; listener.stopBeingLeader(); } catch (Exception ex) { log.makeAlert(ex, "listener.stopBeingLeader() failed. Unable to stopBeingLeader").emit(); } } }, Execs.singleThreaded(StringUtils.format("LeaderSelector[%s]", latchPath)) ); return leaderLatch.getAndSet(newLeaderLatch); }</code><technical_language>zookeeper a term concept? is benefit another term instead of inheriting in zookeeper</technical_language>

Target:
private LeaderLatch createNewLeaderLatch() { final LeaderLatch newLeaderLatch = new LeaderLatch( curator, latchPath, self.getHostAndPortToUse() ); newLeaderLatch.addListener( new LeaderLatchListener() { @Override public void isLeader() { try { if (leader) { log.warn("I'm being asked to become leader. But I am already the leader. Ignored event."); return; } leader = true; term++; listener.becomeLeader(); } catch (Exception ex) { log.makeAlert(ex, "listener becomeLeader() failed. Unable to become leader").emit(); final LeaderLatch oldLatch = createNewLeaderLatch(); CloseQuietly.close(oldLatch); leader = false; try { Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 5000)); leaderLatch.get().start(); } catch (Exception e) { log.makeAlert(e, "I am a zombie").emit(); } } } @Override public void notLeader() { try { if (!leader) { log.warn("I'm being asked to stop being leader. But I am not the leader. Ignored event."); return; } leader = false; listener.stopBeingLeader(); } catch (Exception ex) { log.makeAlert(ex, "listener.stopBeingLeader() failed. Unable to stopBeingLeader").emit(); } } }, listenerExecutor ); return leaderLatch.getAndSet(newLeaderLatch); }
Source:
<code>public String getZoneGroupName(int zoneID, short groupID) { if (zoneGroupIdNameMap == null) { return null; } if (zoneGroupIdNameMap.get(zoneID) != null) { if (zoneGroupIdNameMap.get(zoneID).groupIdNames != null) { if (zoneGroupIdNameMap.get(zoneID).groupIdNames.get(groupID) != null) { <START> return zoneGroupIdNameMap.get(zoneID).groupIdNames.get(groupID); <END> } } } return null; }</code><technical_language>reason call get method multiple times? zoneGroupIdNameMap.get(zoneID) is called times (one time enough) groupIdNames.get(groupID) is called (onen time enough) So, instead of call get if is null call again, store result a local variable reuse it</technical_language>

Target:
public String getZoneGroupName(int zoneID, short groupID) { if (zoneGroupIdNameMap == null) { return null; } final ZoneGroupsNameAndIDMap tmp = zoneGroupIdNameMap.get(zoneID); return tmp != null ? tmp.getGroupName(groupID) : null; }
Source:
<code>public RemoveMembersFromConsumerGroupOptions(Collection<MemberToRemove> members) { <START> this.members = new HashSet<>(members); <END> }</code><technical_language>semantics for empty collection (it "remove nothing" originally, change "remove all"), I wondering if do a check if members is empty throw exception if empty? log a WARNING empty implies "remove all" now</technical_language>

Target:
public RemoveMembersFromConsumerGroupOptions(Collection<MemberToRemove> members) { if (members.isEmpty()) { throw new IllegalArgumentException("Invalid empty members has been provided"); } this.members = new HashSet<>(members); }
Source:
<code>public static byte[] getChecksum(String algorithm, File file) throws NoSuchAlgorithmException, IOException { HashFunction hashFunction = null; <START> switch (algorithm) { <END> case MD5: hashFunction = Hashing.md5(); break; case SHA1: hashFunction = Hashing.sha1(); break; case SHA256: hashFunction = Hashing.sha256(); break; default: throw new NoSuchAlgorithmException(algorithm); } HashCode hash = Files.asByteSource(file).hash(hashFunction); return hash.asBytes(); }</code><technical_language>ensure run casing issues this be: suggestion switch (algorithm.toUpperCase()) {</technical_language>

Target:
public static byte[] getChecksum(String algorithm, File file) throws NoSuchAlgorithmException, IOException { HashFunction hashFunction = null; switch (algorithm.toUpperCase()) { case MD5: hashFunction = Hashing.md5(); break; case SHA1: hashFunction = Hashing.sha1(); break; case SHA256: hashFunction = Hashing.sha256(); break; default: throw new NoSuchAlgorithmException(algorithm); } HashCode hash = Files.asByteSource(file).hash(hashFunction); return hash.asBytes(); }
Source:
<code>private File getRecordFile(String testName) { URL folderUrl = InterceptorManager.class.getClassLoader().getResource("."); File folderFile = new File(folderUrl.getPath() + RECORD_FOLDER); if (!folderFile.exists()) { if (folderFile.mkdir()) { logger.verbose("Created directory: {}", folderFile.getPath()); } } <START> String filePath = folderFile.getPath() + "/" + testName + ".json"; <END> if (Files.notExists(Paths.get(filePath))) { throw logger.logExceptionAsError(new RuntimeException(String.format( "Missing playback file. File path: %s. ", filePath))); } logger.info("==> Playback file path: " + filePath); return new File(filePath); }</code><technical_language>Instead of generating file path, checking existence, failing get file java File playbackFile = new File(folderFile, testName + ".json"); if (!playbackFile.exists()) { // throw exception } return playbackFile;</technical_language>

Target:
private File getRecordFile(String testName) { URL folderUrl = InterceptorManager.class.getClassLoader().getResource("."); File folderFile = new File(folderUrl.getPath() + RECORD_FOLDER); if (!folderFile.exists()) { if (folderFile.mkdir()) { logger.verbose("Created directory: {}", folderFile.getPath()); } } File playbackFile = new File(folderFile, testName + ".json"); if (!playbackFile.exists()) { throw logger.logExceptionAsError(new RuntimeException(String.format( "Missing playback file. File path: %s. ", playbackFile))); } logger.info("==> Playback file path: " + playbackFile); return playbackFile; }