auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public boolean equals(Object o) { <END> if (!(o instanceof ObjectProperty)) { return false; } ObjectProperty that = (ObjectProperty) o; if (properties != null ? !properties.equals(that.properties) : that.properties != null) { return false; } return super.equals(o); }</code><technical_language>possibly add if (this == o) { return true; }</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ObjectProperty)) { return false; } ObjectProperty that = (ObjectProperty) o; if (properties != null ? !properties.equals(that.properties) : that.properties != null) { return false; } return super.equals(o); }
Source:
<code>public void invokeCallbackMethods() { initCommandExecutor(); CommandEntity cmdEntity; for (Iterator<Entry<Guid, CommandCallBack>> iterator = cmdCallBackMap.entrySet().iterator(); iterator.hasNext();) { Entry<Guid, CommandCallBack> entry = iterator.next(); Guid cmdId = entry.getKey(); CommandCallBack callBack = entry.getValue(); CommandStatus status = coco.getCommandStatus(cmdId); switch (status) { case FAILED: try { callBack.onFailed(cmdId, coco.getChildCommandIds(cmdId)); } catch (Exception ex) { handleError(ex, status, cmdId); } <START> coco.updateCallBackNotified(cmdId); <END> iterator.remove(); break; case SUCCEEDED: try { callBack.onSucceeded(cmdId, coco.getChildCommandIds(cmdId)); coco.updateCallBackNotified(cmdId); iterator.remove(); } catch (Exception ex) { handleError(ex, status, cmdId); } coco.updateCallBackNotified(cmdId); iterator.remove(); break; case ACTIVE: cmdEntity = coco.getCommandEntity(cmdId); if (cmdEntity.isExecuted()) { try { callBack.doPolling(cmdId, coco.getChildCommandIds(cmdId)); } catch (Exception ex) { handleError(ex, status, cmdId); } } break; default: break; } } }</code><technical_language>I suggested before... switch..case a try... catch block, IMHO</technical_language>

Target:
public void invokeCallbackMethods() { initCommandExecutor(); CommandEntity cmdEntity; for (Iterator<Entry<Guid, CommandCallBack>> iterator = cmdCallBackMap.entrySet().iterator(); iterator.hasNext(); ) { Entry<Guid, CommandCallBack> entry = iterator.next(); Guid cmdId = entry.getKey(); CommandCallBack callBack = entry.getValue(); CommandStatus status = coco.getCommandStatus(cmdId); try { switch (status) { case FAILED: callBack.onFailed(cmdId, coco.getChildCommandIds(cmdId)); coco.updateCallBackNotified(cmdId); iterator.remove(); break; case SUCCEEDED: callBack.onSucceeded(cmdId, coco.getChildCommandIds(cmdId)); coco.updateCallBackNotified(cmdId); iterator.remove(); break; case ACTIVE: cmdEntity = coco.getCommandEntity(cmdId); if (cmdEntity.isExecuted()) { callBack.doPolling(cmdId, coco.getChildCommandIds(cmdId)); } break; default: break; } } catch (Exception ex) { handleError(ex, status, cmdId); if (CommandStatus.FAILED.equals(status)) { coco.updateCallBackNotified(cmdId); iterator.remove(); } } } }
Source:
<code>public void testByteBuf2BytesEmptyByteBuf() { ByteBuf buf = Unpooled.buffer(); ArrayAsserts.assertArrayEquals(new byte[]{}, ByteBufUtils.byteBuf2Bytes(buf)); <START> buf.release(); <END> }</code><technical_language>nit: please perform release calls in a finally block ByteBufs get released if assert fails</technical_language>

Target:
public void testByteBuf2BytesEmptyByteBuf() { ByteBuf buf = Unpooled.buffer(); try { ArrayAsserts.assertArrayEquals(new byte[]{}, ByteBufUtils.byteBuf2Bytes(buf)); } finally { buf.release(); } }
Source:
<code>void copyFiles(File srcDir, File dstDir, String filter) throws IOException { File[] list; <START> if ((list = srcDir.listFiles()) != null) { <END> for (File file: list) { String name = file.getName(); if (name.startsWith(filter)) { File dest = new File(dstDir, name); LOG.info("Renaming " + file + " to " + dest); if (!file.renameTo(dest)) { throw new IOException("Unable to rename " + file + " to " + dest); } } } } }</code><technical_language>Please var assignment (list = srcDir.listFiles()) object reference. File[] list = srcDir.listFiles();</technical_language>

Target:
void copyFiles(File srcDir, File dstDir, String filter) throws IOException { File[] list = srcDir.listFiles(); if (list != null) { for (File file: list) { String name = file.getName(); if (name.startsWith(filter)) { File dest = new File(dstDir, name); LOG.info("Renaming " + file + " to " + dest); if (!file.renameTo(dest)) { throw new IOException("Unable to rename " + file + " to " + dest); } } } } }
Source:
<code>public void applyStreamLinks() { for (String id : streamLinks.keySet()) { StreamMeta s = getStream(id); for (Map.Entry<Operator.OutputPort<?>, Operator.InputPort<?>> pair : streamLinks.get(id).entries()) { if (s.getSource() == null) { Operator.OutputPort<?> outputPort = pair.getKey(); while (outputPort instanceof ProxyOutputPort) { outputPort = ((ProxyOutputPort)outputPort).get(); } s.setSource(outputPort); } Operator.InputPort<?> inputPort = pair.getValue(); while (inputPort instanceof ProxyInputPort) { <START> inputPort = ((ProxyInputPort)inputPort).get(); <END> } s.addSink(inputPort); } } }</code><technical_language>raw type warning. Please review entire pull request for similar warnings</technical_language>

Target:
public void applyStreamLinks() { for (String id : streamLinks.keySet()) { StreamMeta s = getStream(id); for (Map.Entry<Operator.OutputPort<?>, Operator.InputPort<?>> pair : streamLinks.get(id).entries()) { if (s.getSource() == null) { Operator.OutputPort<?> outputPort = pair.getKey(); while (outputPort instanceof ProxyOutputPort) { outputPort = ((ProxyOutputPort<?>)outputPort).get(); } s.setSource(outputPort); } Operator.InputPort<?> inputPort = pair.getValue(); while (inputPort instanceof ProxyInputPort) { inputPort = ((ProxyInputPort<?>)inputPort).get(); } s.addSink(inputPort); } } }
Source:
<code>public Long getContentLength() { try { if (Files.isSymbolicLink(file) && Files.notExists(file)) { <START> return 0L; <END> } return Files.size(file); } catch (IOException e) { throw new RuntimeException(e); } }</code><technical_language>I this null</technical_language>

Target:
public Long getContentLength() { try { if (Files.isSymbolicLink(file) && Files.notExists(file)) { return null; } return Files.size(file); } catch (IOException e) { throw new RuntimeException(e); } }
Source:
<code>protected StringWriter doInBackground(java.lang.Object... params) { if (params.length != 2) throw new IllegalArgumentException("The parameters to " + TextLoadAsyncTask.class.getName() + " must be (1) the file location and (2) the text view to update"); final String location = (String) params[0]; <START> mTextView = (TextView) params[1]; <END> FileInputStream inputStream = null; Scanner sc = null; StringWriter source = new StringWriter(); BufferedWriter bufferedWriter = new BufferedWriter(source); try { inputStream = new FileInputStream(location); sc = new Scanner(inputStream); while (sc.hasNextLine()) { bufferedWriter.append(sc.nextLine()); if (sc.hasNextLine()) bufferedWriter.append("\n"); } bufferedWriter.close(); IOException exc = sc.ioException(); if (exc != null) throw exc; } catch (IOException e) { finish(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { finish(); } } if (sc != null) { sc.close(); } } return source; }</code><technical_language>prefer set TextView reference in a constructor; semantics of AsyncTask grant fields set in constructor onPreExecute 'done' doInBrackground is started</technical_language>

Target:
protected StringWriter doInBackground(java.lang.Object... params) { if (params.length != 1) { throw new IllegalArgumentException("The parameter to " + TextLoadAsyncTask.class.getName() + " must be (1) the file location"); } final String location = (String) params[0]; FileInputStream inputStream = null; Scanner sc = null; StringWriter source = new StringWriter(); BufferedWriter bufferedWriter = new BufferedWriter(source); try { inputStream = new FileInputStream(location); sc = new Scanner(inputStream); while (sc.hasNextLine()) { bufferedWriter.append(sc.nextLine()); if (sc.hasNextLine()) bufferedWriter.append("\n"); } bufferedWriter.close(); IOException exc = sc.ioException(); if (exc != null) throw exc; } catch (IOException e) { Log_OC.e(TAG, e.getMessage(), e); finish(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { Log_OC.e(TAG, e.getMessage(), e); finish(); } } if (sc != null) { sc.close(); } } return source; }
Source:
<code>public double variance() { <START> return ( (entries > 1) ? newS /(entries - 1) : 0.0 ); <END> }</code><technical_language>Space /</technical_language>

Target:
public double variance() { return mean2 / (entries - 1.0d); }
Source:
<code>private void updatePatternPathRouter() throws WebSocketEndpointAnnotationException { endpointPatternPathRouter = PatternPathRouter.create(); <START> for (Map.Entry entry : webSocketEndpointMap.entrySet()) { <END> Object endpoint = entry.getValue(); endpointPatternPathRouter.add(new EndpointDispatcher().getUri(endpoint), endpoint); } }</code><technical_language>Java 8 streams</technical_language>

Target:
private void updatePatternPathRouter() { endpointPatternPathRouter = PatternPathRouter.create(); webSocketEndpointMap.entrySet().forEach( entry -> endpointPatternPathRouter.add(entry.getKey(), entry.getValue()) ); }
Source:
<code>protected void postStart() { List<PrioritizedMethod> methods = new ArrayList<>(componentLookup.size()); for (Component c : componentLookup.values()) { <START> if (c != null) <END> Collections.addAll(methods, c.postStartMethods); } invokePrioritizedMethods(methods); }</code><technical_language>a component null</technical_language>

Target:
protected void postStart() { List<PrioritizedMethod> methods = new ArrayList<>(componentLookup.size()); for (Component c : componentLookup.values()) { Collections.addAll(methods, c.postStartMethods); } invokePrioritizedMethods(methods); }
Source:
<code>public void saveContent(DownloadBundle bundle, AthenaUser user) { List<Long> idV4s = bundle.getVocabularyV4Ids(); try (FileOutputStream fout = new FileOutputStream(fileHelper.getZipPath(bundle.getUuid())); ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fout))) { List ids; List<? extends ISaver> savers; switch (bundle.getCdmVersion()) { case V4_5: ids = idV4s; savers = saversV4; break; case V5: ids = vocabularyConversionRepository.findIdsV5ByIdsV4(idV4s); savers = saversV5; break; default: throw new NotExistException("No savers for version " + bundle.getCdmVersion(), CDMVersion.class); } SaverService saver = new SaverService(downloadBundleService, ids, fileHelper); bundle = saver.save(zos, bundle, savers); zipWriter.addCPT4Utility(zos, bundle); LOGGER.info("Bundle is saved in zip: {}", bundle); updateStatus(bundle, DownloadBundleStatus.READY); final Map<String, String> includedVocabularies = bundle.getVocabularies().stream().map(DownloadItem::getVocabularyConversion) <START> .filter(vocab -> !vocab.getOmopReqValue()).collect(Collectors.toMap(VocabularyConversion::getIdV5, VocabularyConversion::getName)); <END> emailService.sendVocabularyDownloadLink(user, urlBuilder.downloadVocabulariesLink(bundle.getUuid()), bundle.getCdmVersion(), bundle.getReleaseVersion(), bundle.getName(), includedVocabularies); } catch (Exception ex) { updateStatus(bundle, DownloadBundleStatus.FAILED); LOGGER.error(ex.getMessage(), ex); emailService.sendFailedSaving(user); } }</code><technical_language>formatted this expression? is tricky read. Please write operation a new line</technical_language>

Target:
public void saveContent(DownloadBundle bundle, AthenaUser user) { List<Long> idV4s = bundle.getVocabularyV4Ids(); try (FileOutputStream fout = new FileOutputStream(fileHelper.getZipPath(bundle.getUuid())); ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fout))) { List ids; List<? extends ISaver> savers; switch (bundle.getCdmVersion()) { case V4_5: ids = idV4s; savers = saversV4; break; case V5: ids = vocabularyConversionRepository.findIdsV5ByIdsV4(idV4s); savers = saversV5; break; default: throw new NotExistException("No savers for version " + bundle.getCdmVersion(), CDMVersion.class); } SaverService saver = new SaverService(downloadBundleService, ids, fileHelper); bundle = saver.save(zos, bundle, savers); zipWriter.addCPT4Utility(zos, bundle); LOGGER.info("Bundle is saved in zip: {}", bundle); updateStatus(bundle, DownloadBundleStatus.READY); final Map<String, String> includedVocabularies = bundle.getVocabularies().stream() .map(DownloadItem::getVocabularyConversion) .filter(vocab -> !vocab.getOmopReqValue()) .collect(toMap(VocabularyConversion::getIdV5, VocabularyConversion::getName)); emailService.sendVocabularyDownloadLink(user, urlBuilder.downloadVocabulariesLink(bundle.getUuid()), bundle.getCdmVersion(), bundle.getReleaseVersion(), bundle.getName(), includedVocabularies); } catch (Exception ex) { updateStatus(bundle, DownloadBundleStatus.FAILED); LOGGER.error(ex.getMessage(), ex); emailService.sendFailedSaving(user); } }
Source:
<code>private Map<String, List<String>> extractHeaders(SlingHttpServletResponse response, HttpCacheConfig cacheConfig) { Map<String, List<String>> headers = new HashMap<>(); List<Pattern> excludedHeaders = Stream.concat(globalHeaderExclusions.stream(), cacheConfig.getExcludedResponseHeaderPatterns().stream()) .collect(Collectors.toList()); <START> List<String> headerNames = new ArrayList<>(); <END> headerNames.addAll(response.getHeaderNames()); for (String headerName : headerNames) { if (!isResponseHeaderExcluded(headerName, excludedHeaders)) { List<String> values = new ArrayList<>(); values.addAll(response.getHeaders(headerName)); headers.put(headerName, values); } } return headers; }</code><technical_language>Arrays.stream(response.getHeaderNames()) .filter(headerName -> !isResponseHeaderExcluded(headerName, excludedHeaders)) .collect(Collectors.toMap(headerName -> headerName, headerName -> response.getHeaders(headerName)));</technical_language>

Target:
private Map<String, List<String>> extractHeaders(SlingHttpServletResponse response, HttpCacheConfig cacheConfig) { List<Pattern> excludedHeaders = Stream.concat(globalHeaderExclusions.stream(), cacheConfig.getExcludedResponseHeaderPatterns().stream()) .collect(Collectors.toList()); return response.getHeaderNames().stream() .filter(headerName -> excludedHeaders.stream() .noneMatch(pattern -> pattern.matcher(headerName).matches()) ).collect( Collectors.toMap(headerName -> headerName, headerName -> new ArrayList<>(response.getHeaders(headerName) ) )); }
Source:
<code>public Session createSession() { Properties properties = new Properties(); if (hostName == null) { throw new IllegalArgumentException("Hostname cannot be null for smtp client."); } properties.setProperty(SMTP_HOST_PROPERTY, hostName); properties.setProperty(SMTP_PORT_PROPERTY, portNumber.toString()); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(Provider.class.getClassLoader()); Session session; if (StringUtils.isNotBlank(userName)) { properties.put(SMTP_AUTH_PROPERTY, TRUE); properties.put(SMTP_START_TLS_ENABLE_PROPERTY, TRUE); session = Session.getInstance(properties, createAuthenticator()); } else { properties.setProperty(SMTP_AUTH_PROPERTY, FALSE); session = Session.getInstance(properties); } <START> Thread.currentThread().setContextClassLoader(originalContextClassLoader); <END> return session; }</code><technical_language>worthwhile reset class loader in a finally block</technical_language>

Target:
public Session createSession() { Properties properties = new Properties(); if (hostName == null) { throw new IllegalArgumentException("Hostname cannot be null for smtp client."); } properties.setProperty(SMTP_HOST_PROPERTY, hostName); properties.setProperty(SMTP_PORT_PROPERTY, portNumber.toString()); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(Provider.class.getClassLoader()); if (StringUtils.isNotBlank(userName)) { properties.put(SMTP_AUTH_PROPERTY, TRUE); properties.put(SMTP_START_TLS_ENABLE_PROPERTY, TRUE); return Session.getInstance(properties, createAuthenticator()); } else { properties.setProperty(SMTP_AUTH_PROPERTY, FALSE); return Session.getInstance(properties); } } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } }
Source:
<code>protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { int length = invokers.size(); int leastActive = -1; int leastCount = 0; int[] leastIndexs = new int[length]; <START> int taotalWeightWithWarmUp = 0; END> int firstWeightWithWarmUp = 0; boolean sameWeight = true; for (int i = 0; i < length; i++) { Invoker<T> invoker = invokers.get(i); int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); int afterWarmup = getWeight(invoker, invocation); if (leastActive == -1 || active < leastActive) { leastActive = active; leastCount = 1; leastIndexs[0] = i; taotalWeightWithWarmUp = afterWarmup; firstWeightWithWarmUp = afterWarmup; sameWeight = true; } else if (active == leastActive) { leastIndexs[leastCount++] = i; taotalWeightWithWarmUp += afterWarmup; if (sameWeight && i > 0 && afterWarmup != firstWeightWithWarmUp) { sameWeight = false; } } } if (leastCount == 1) { return invokers.get(leastIndexs[0]); } if (!sameWeight && taotalWeightWithWarmUp > 0) { int offsetWeight = random.nextInt(taotalWeightWithWarmUp) + 1; for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexs[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); if (offsetWeight <= 0) return invokers.get(leastIndex); } } return invokers.get(leastIndexs[random.nextInt(leastCount)]); }</code><technical_language>typo</technical_language>

Target:
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { int length = invokers.size(); int leastActive = -1; int leastCount = 0; int[] leastIndexes = new int[length]; int totalWeight = 0; int firstWeight = 0; boolean sameWeight = true; for (int i = 0; i < length; i++) { Invoker<T> invoker = invokers.get(i); int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); int afterWarmup = getWeight(invoker, invocation); if (leastActive == -1 || active < leastActive) { leastActive = active; leastCount = 1; leastIndexes[0] = i; totalWeight = afterWarmup; firstWeight = afterWarmup; sameWeight = true; } else if (active == leastActive) { leastIndexes[leastCount++] = i; totalWeight += afterWarmup; if (sameWeight && i > 0 && afterWarmup != firstWeight) { sameWeight = false; } } } if (leastCount == 1) { return invokers.get(leastIndexes[0]); } if (!sameWeight && totalWeight > 0) { int offsetWeight = ThreadLocalRandom.current().nextInt(totalWeight) + 1; for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexes[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); if (offsetWeight <= 0) return invokers.get(leastIndex); } } return invokers.get(leastIndexes[ThreadLocalRandom.current().nextInt(leastCount)]); }
Source:
<code>LocalCacheManager(AlluxioConfiguration conf, MetaStore metaStore, PageStore pageStore, CacheEvictor evictor) { mMetaStore = metaStore; mPageStore = pageStore; mEvictor = evictor; mPageSize = conf.getBytes(PropertyKey.USER_CLIENT_CACHE_PAGE_SIZE); mAsyncWrite = conf.getBoolean(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_ENABLED); mCacheSize = pageStore.getCacheSize(); for (int i = 0; i < LOCK_SIZE; i++) { mPageLocks[i] = new ReentrantReadWriteLock(); } mPendingRequests = new ConcurrentHashSet<>(); mAsyncCacheExecutor = mAsyncWrite <START> ? new ThreadPoolExecutor(0, conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), <END> 60, TimeUnit.SECONDS, new SynchronousQueue<>()) : null; Metrics.registerGauges(mCacheSize, mMetaStore); }</code><technical_language>a synchronous queue, set core threads # of async write threads</technical_language>

Target:
LocalCacheManager(AlluxioConfiguration conf, MetaStore metaStore, PageStore pageStore, CacheEvictor evictor) { mMetaStore = metaStore; mPageStore = pageStore; mEvictor = evictor; mPageSize = conf.getBytes(PropertyKey.USER_CLIENT_CACHE_PAGE_SIZE); mAsyncWrite = conf.getBoolean(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_ENABLED); mCacheSize = pageStore.getCacheSize(); for (int i = 0; i < LOCK_SIZE; i++) { mPageLocks[i] = new ReentrantReadWriteLock(); } mPendingRequests = new ConcurrentHashSet<>(); mAsyncCacheExecutor = mAsyncWrite ? new ThreadPoolExecutor(conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), 60, TimeUnit.SECONDS, new SynchronousQueue<>()) : null; Metrics.registerGauges(mCacheSize, mMetaStore); }
Source:
<code>public void setUp() { super.setUp(); VisitRepository visitRepository = new VisitRepository(restApi, visitDAO, locationDAO, new EncounterDAO()); presenter = new LoginPresenter(restApi, visitRepository, locationDAO, userService, view, openMRS, <START> <<<<<<< HEAD openMRSLogger, authorizationManager); ======= openMRSLogger, authorizationManager); >>>>>>> removed context from presenter <END> mockStaticMethods(); }</code><technical_language>care of this merge conflict</technical_language>

Target:
public void setUp() { super.setUp(); VisitRepository visitRepository = new VisitRepository(restApi, visitDAO, locationDAO, new EncounterDAO()); presenter = new LoginPresenter(restApi, visitRepository, locationDAO, userService, view, openMRS, openMRSLogger, authorizationManager); mockStaticMethods(); }
Source:
<code>public boolean isLiteralText() { <START> return blobExpression == null ? false : blobExpression.isLiteralText(); <END> }</code><technical_language>sure, choose this format: blobExpression == null ? false : blobExpression.isLiteralText(); this one: blobExpression != null && blobExpression.isLiteralText();</technical_language>

Target:
public boolean isLiteralText() { return blobExpression != null && blobExpression.isLiteralText(); }
Source:
<code>public void savePatient_shouldFailSaveIfPatientsWithSameIdentifierAreSaved() { isSavePatientThreadsafe = new AtomicBoolean(false); UserContext ctx = Context.getUserContext(); Patient patient1 = new Patient(); patient1.setGender("M"); patient1.addName(new PersonName("Test1", "Sam", "Test")); Patient patient2 = new Patient(); patient2.setGender("M"); patient2.addName(new PersonName("Test2", "Samuel", "Test")); Runnable r1 = () -> savePatientOnThread(ctx, patient1); Runnable r2 = () -> savePatientOnThread(ctx, patient2); Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1.start(); t2.start(); <START> assertTrue(isSavePatientThreadsafe.get()); <END> }</code><technical_language>check for assertFalse default is set false</technical_language>

Target:
public void savePatient_shouldFailSaveIfPatientsWithSameIdentifierAreSaved() { isSavePatientThreadUnSafe = new AtomicBoolean(false); UserContext ctx = Context.getUserContext(); Patient patient1 = new Patient(); patient1.setGender("M"); patient1.addName(new PersonName("Test1", "Sam", "Test")); Patient patient2 = new Patient(); patient2.setGender("M"); patient2.addName(new PersonName("Test2", "Samuel", "Test")); Runnable r1 = () -> savePatientOnThread(ctx, patient1); Runnable r2 = () -> savePatientOnThread(ctx, patient2); Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1.start(); t2.start(); try { t1.join(); } catch (InterruptedException e) { } assertTrue("IdentifierNotUniqueException not thrown, method not Threadsafe", isSavePatientThreadUnSafe.get()); deleteAllData(); }
Source:
<code>public void applyConfig(Collection<PubSubConfig.Publisher> publishers) { Set<String> existingKeys = new HashSet<String>(subscribers.keySet()); for (final PubSubConfig.Publisher p : publishers) { Map<String, List<SubscribeCommand>> syncCommands; <START> final String key = p.getKey(); <END> existingKeys.remove(key); SubscribeTask task = subscribers.get(key); if (task == null) { try { task = new SubscribeTask(new SubscribeProcess( p.getUri(), new Subscriber())); } catch (Exception e) { printError(key, e); continue; } subscribers.put(key, task); } try { syncCommands = task.process.sync(p); } catch (Exception e) { printError(key, e); continue; } if (syncCommands.size() > 0) { task.stop(); task.start(p, syncCommands, key); } } for (String key : existingKeys) { SubscribeTask task = subscribers.get(key); task.close(); subscribers.remove(key); } }</code><technical_language>nit: i is clearer inline p.getKey()</technical_language>

Target:
public void applyConfig(Collection<PubSubConfig.Publisher> publishers) { Set<String> existingKeys = new HashSet<String>(subscribers.keySet()); for (final PubSubConfig.Publisher p : publishers) { existingKeys.remove(p.getKey()); SubscribeTask task = subscribers.get(p.getKey()); if (task == null) { try { SubscribeProcess sp = new SubscribeProcess( p.getUri(), new SubscriptionState()); task = new SubscribeTask(sp, p.getKey()); task.start(p); subscribers.put(p.getKey(), task); } catch (Exception e) { printError(p.getKey(), e); } } else { task.updatePublisher(p); } } for (String key : existingKeys) { SubscribeTask task = subscribers.remove(key); task.close(); } }
Source:
<code>void validateSpans() throws Exception { List<Span> spans = SpanCollectorForTesting.getInstance().getCollectedSpans(); assertThat(spans.size(), is(equalTo(2))); Span serverSpan = spans.get(0); assertThat(serverSpan.getTrace_id(), is(equalTo(spans.get(1).getTrace_id()))); validateSpan(serverSpan, Arrays.asList("ss", "sr")); <START> Optional<BinaryAnnotation> binaryAnnotation = <END> serverSpan.getBinary_annotations().stream().filter(b -> b.getKey().equals(GrpcKeys.GRPC_REMOTE_ADDR)).findFirst(); assertTrue("Could not find binary annotation: " + GrpcKeys.GRPC_REMOTE_ADDR, binaryAnnotation.isPresent()); validateSpan(spans.get(1), Arrays.asList("cs", "cr")); }</code><technical_language>of this consistent, right? nice show is (ex ip:port) some assertj slickness.. java assertThat(span.binaryAnnotations) .filteredOn(b -> b.key.equals(Constants.SERVER_ADDR)) .extracting(b -> new String(b.value)) .containsOnly("host:port");</technical_language>

Target:
void validateSpans() throws Exception { List<Span> spans = SpanCollectorForTesting.getInstance().getCollectedSpans(); assertThat(spans.size()).isEqualTo(2); Span serverSpan = spans.get(0); assertThat(serverSpan.getTrace_id()).isEqualTo(spans.get(1).getTrace_id()); validateSpan(serverSpan, Arrays.asList("sr", "ss")); assertThat(serverSpan.getBinary_annotations()) .filteredOn(b -> b.key.equals(GrpcKeys.GRPC_REMOTE_ADDR)) .extracting(b -> new String(b.value)) .has(new Condition<>(b -> b.matches("^/127.0.0.1:[\\d]+$"), "a local IP address"), atIndex(0)); validateSpan(spans.get(1), Arrays.asList("cs", "cr")); }
Source:
<code>@Test public void testNoCacheHeadersAreSet() throws Exception { List<NameValuePair> responseHeaders = j.createWebClient() .goTo("view/all/itemCategories", "application/json") .getWebResponse() .getResponseHeaders(); final Map<String, String> values = new HashMap<>(); for(NameValuePair p : responseHeaders) { values.put(p.getName(), p.getValue()); } String resp = values.get("Cache-Control"); assertThat(resp, is("no cache, no store, must revalidate")); assertThat(values.get("Expires"), is("0")); <START> assertThat(values.get("Pragma"), is("no-cache")); <END> }</code><technical_language>FWIW easier write: java WebResponse rsp = j.createWebClient().goTo("view/all/itemCategories", "application/json").getWebResponse(); assertEquals("no cache, store, revalidate", rsp.getResponseHeaderValue("Cache-Control")); assertEquals("0", rsp.getResponseHeaderValue("Expires")); assertEquals("no cache", rsp.getResponseHeaderValue("Pragma"));</technical_language>

Target:
@Test public void testNoCacheHeadersAreSet() throws Exception { List<NameValuePair> responseHeaders = j.createWebClient() .goTo("view/all/itemCategories", "application/json") .getWebResponse() .getResponseHeaders(); final Map<String, String> values = new HashMap<>(); for(NameValuePair p : responseHeaders) { values.put(p.getName(), p.getValue()); } String resp = values.get("Cache-Control"); assertThat(resp, is("no-cache, no-store, must-revalidate")); assertThat(values.get("Expires"), is("0")); assertThat(values.get("Pragma"), is("no-cache")); }
Source:
<code>public void getInstance_differentConfigurationsShouldNotBlockEachOther() throws InterruptedException { final CountDownLatch bgThreadStarted = new CountDownLatch(1); final CountDownLatch realm2CreatedLatch = new CountDownLatch(1); final RealmConfiguration config1 = configFactory.createConfigurationBuilder() <START> .name("config1") <END> .initialData(new Realm.Transaction() { @Override public void execute(Realm realm) { TestHelper.awaitOrFail(realm2CreatedLatch); } }) .build(); RealmConfiguration config2 = configFactory.createConfigurationBuilder() .name("config2") .build(); Thread thread = new Thread(new Runnable() { @Override public void run() { bgThreadStarted.countDown(); Realm realm = Realm.getInstance(config1); realm.close(); } }); thread.start(); TestHelper.awaitOrFail(bgThreadStarted); Realm realm = Realm.getInstance(config2); realm2CreatedLatch.countDown(); realm.close(); thread.join(); }</code><technical_language>database filename ends .realm</technical_language>

Target:
public void getInstance_differentConfigurationsShouldNotBlockEachOther() throws InterruptedException { final CountDownLatch bgThreadStarted = new CountDownLatch(1); final CountDownLatch realm2CreatedLatch = new CountDownLatch(1); final RealmConfiguration config1 = configFactory.createConfigurationBuilder() .name("config1.realm") .initialData(new Realm.Transaction() { @Override public void execute(Realm realm) { bgThreadStarted.countDown(); TestHelper.awaitOrFail(realm2CreatedLatch); } }) .build(); RealmConfiguration config2 = configFactory.createConfigurationBuilder() .name("config2.realm") .build(); Thread thread = new Thread(new Runnable() { @Override public void run() { Realm realm = Realm.getInstance(config1); realm.close(); } }); thread.start(); TestHelper.awaitOrFail(bgThreadStarted); Realm realm = Realm.getInstance(config2); realm2CreatedLatch.countDown(); realm.close(); thread.join(); }
Source:
<code>public void run() { while (!shutdown) { try { if (PluginImpl.getInstance() != null && PluginImpl.getInstance().getConfig() != null && isConnected()) { IGerritHudsonTriggerConfig activeConfig = PluginImpl.getInstance().getConfig(); SshConnection sshConnection = SshConnectionFactory.getConnection( activeConfig.getGerritHostName(), activeConfig.getGerritSshPort(), activeConfig.getGerritProxy(), activeConfig.getGerritAuthentication() ); setGerritProjects(readProjects(sshConnection.executeCommandReader(GERRIT_LS_PROJECTS))); sshConnection.disconnect(); <START> runMissedPatchSets(); <END> } } catch (SshException ex) { logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex); } catch (IOException ex) { logger.error("Could not read stream with Gerrit projects: ", ex); } try { synchronized (this) { wait(UPDATE_DELAY); } } catch (InterruptedException ex) { logger.warn("InterruptedException: ", ex); break; } } PluginImpl.getInstance().removeListener(this); }</code><technical_language>This run minute while Jenkins is connected Gerrit, I is good, intended</technical_language>

Target:
public void run() { while (!shutdown) { try { if (PluginImpl.getInstance() != null && PluginImpl.getInstance().getConfig() != null && isConnected()) { IGerritHudsonTriggerConfig activeConfig = PluginImpl.getInstance().getConfig(); SshConnection sshConnection = SshConnectionFactory.getConnection( activeConfig.getGerritHostName(), activeConfig.getGerritSshPort(), activeConfig.getGerritProxy(), activeConfig.getGerritAuthentication() ); setGerritProjects(readProjects(sshConnection.executeCommandReader(GERRIT_LS_PROJECTS))); sshConnection.disconnect(); } } catch (SshException ex) { logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex); } catch (IOException ex) { logger.error("Could not read stream with Gerrit projects: ", ex); } try { synchronized (this) { wait(UPDATE_DELAY); } } catch (InterruptedException ex) { logger.warn("InterruptedException: ", ex); break; } } PluginImpl.getInstance().removeListener(this); }
Source:
<code>private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); <START> StringBuilder builder = new StringBuilder(attributeDataPath); <END> String rawPath = locator.getRawPath(); builder.append(rawPath); String pathname = builder.toString(); if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }</code><technical_language>lines 82 86 collapse to: String pathname = attributeDataPath + locator.getRawPath();</technical_language>

Target:
private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); String rawPath = locator.getRawPath(); String pathname = attributeDataPath + rawPath; if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }
Source:
<code>public static double number(Object value) { if (value == null) return Double.NaN; if (value instanceof Number) { Number number = (Number) value; return number.doubleValue(); } if (value instanceof String) { String text = (String) value; try { Number number = (Number) gets(text, Number.class); return number.doubleValue(); } catch (Throwable e) { throw new IllegalArgumentException("Unable to decode '" + text + "' as a number"); } } <START> if (value instanceof ComplexAttribute) { <END> ComplexAttribute complexAttrib = (ComplexAttribute) value; Iterator<Property> iterator = (Iterator<Property>) complexAttrib.getValue().iterator(); if (iterator.hasNext()) { Class valueClass = iterator.next().getType().getBinding(); Object result = Converters.convert(value, valueClass); Number number = (Number) result; return number.doubleValue(); } } if (value instanceof Expression) { throw new IllegalArgumentException("Cannot deal with un evaulated Expression"); } throw new IllegalArgumentException( "Unable to evaulate " + value.getClass() + " in a numeric context"); }</code><technical_language>get there, calling code evaluate expression/attribute here</technical_language>

Target:
public static double number(Object value) { if (value == null) return Double.NaN; if (value instanceof Number) { Number number = (Number) value; return number.doubleValue(); } if (value instanceof String) { String text = (String) value; try { Number number = (Number) gets(text, Number.class); return number.doubleValue(); } catch (Throwable e) { throw new IllegalArgumentException("Unable to decode '" + text + "' as a number"); } } if (value instanceof Expression) { throw new IllegalArgumentException("Cannot deal with un evaulated Expression"); } throw new IllegalArgumentException( "Unable to evaulate " + value.getClass() + " in a numeric context"); }
Source:
<code><START> protected boolean isBackChannelLogoutRequest(final HttpServletRequest request) { <END> return "POST".equals(request.getMethod()) && !isMultipartRequest(request) && CommonUtils.isNotBlank(CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters)); }</code><technical_language>this private</technical_language>

Target:
private boolean isBackChannelLogoutRequest(final HttpServletRequest request) { return "POST".equals(request.getMethod()) && !isMultipartRequest(request) && CommonUtils.isNotBlank(CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters)); }
Source:
<code>public void testSingleRollingFileEmptyWindowsWrite() { SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter(); testSingleRollingFileEmptyWindowsWriteHelper(writer); String singleFileName = testMeta.getDir() + File.separator + SINGLE_FILE; int numberOfFiles = new File(testMeta.getDir()).listFiles().length; String correctContents = "0\n" + "1\n" + "2\n"; checkOutput(0, singleFileName, correctContents); <START> Assert.assertEquals("More than one File in Directory", 1, numberOfFiles); <END> }</code><technical_language>Flip assert order. Check number of files output</technical_language>

Target:
public void testSingleRollingFileEmptyWindowsWrite() { SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter(); testSingleRollingFileEmptyWindowsWriteHelper(writer); String singleFileName = testMeta.getDir() + File.separator + SINGLE_FILE; int numberOfFiles = new File(testMeta.getDir()).listFiles().length; Assert.assertEquals("More than one File in Directory", 1, numberOfFiles); String correctContents = "0\n" + "1\n" + "2\n"; checkOutput(0, singleFileName, correctContents); }
Source:
<code>public static CRUD grantServiceAccountInstanceCreateReadUpdateDelete(GetPermissionsRequest request, ServiceAccount serviceAccount) { <START> info().serviceAccountID(serviceAccount.getId()) <END> .datasetID(request.getDatasetID()) .log("granting full CRUD instance permissions to service account"); return new CRUD().permit(CREATE, READ, UPDATE, DELETE); }</code><technical_language>In some places ID (datasetID) others Id (getId), for 'ID'</technical_language>

Target:
public static CRUD grantServiceAccountInstanceCreateReadUpdateDelete(GetPermissionsRequest request, ServiceAccount serviceAccount) { info().serviceAccountID(serviceAccount.getID()) .datasetID(request.getDatasetID()) .log("granting full CRUD instance permissions to service account"); return new CRUD().permit(CREATE, READ, UPDATE, DELETE); }
Source:
<code>void build(Repository git, TagSet old, TagMatcher m) { if (old != null && m != null && refresh(old, m)) { return; } TagWalk rw = new TagWalk(git); rw.setRetainBody(false); try { for (Ref ref : git.getRefDatabase().getRefs(RefDatabase.ALL).values()) { if (skip(ref)) { continue; } else if (isTag(ref)) { addTag(rw, git.peel(ref)); } else { addRef(rw, ref); } } TagCommit c; while ((c = (TagCommit) rw.next()) != null) { BitSet mine = c.refFlags; int pCnt = c.getParentCount(); for (int pIdx = 0; pIdx < pCnt; pIdx++) { ((TagCommit) c.getParent(pIdx)).refFlags.or(mine); } } } catch (IOException e) { <START> log.warn("Repository " + projectName + " has corruption", e); <END> } finally { rw.release(); } }</code><technical_language>(not this change) This message a bit misleading. :)</technical_language>

Target:
void build(Repository git, TagSet old, TagMatcher m) { if (old != null && m != null && refresh(old, m)) { return; } TagWalk rw = new TagWalk(git); rw.setRetainBody(false); try { for (Ref ref : git.getRefDatabase().getRefs(RefDatabase.ALL).values()) { if (skip(ref)) { continue; } else if (isTag(ref)) { addTag(rw, git.peel(ref)); } else { addRef(rw, ref); } } TagCommit c; while ((c = (TagCommit) rw.next()) != null) { BitSet mine = c.refFlags; int pCnt = c.getParentCount(); for (int pIdx = 0; pIdx < pCnt; pIdx++) { ((TagCommit) c.getParent(pIdx)).refFlags.or(mine); } } } catch (IOException e) { log.warn("Error building tags for repository " + projectName, e); } finally { rw.release(); } }
Source:
<code>public Subscription getSubscription(final String subscriptionId) throws NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { try { return subscriptionsCache.get(subscriptionId); } catch (final UncheckedExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof NoSuchSubscriptionException) { <START> throw new NoSuchSubscriptionException(e.getCause().getMessage()); <END> } throw new ServiceTemporarilyUnavailableException(e.getCause().getMessage()); } catch (final ExecutionException e) { throw new ServiceTemporarilyUnavailableException(e.getCause().getMessage()); } }</code><technical_language>throw</technical_language>

Target:
public Subscription getSubscription(final String subscriptionId) throws NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { try { return subscriptionsCache.get(subscriptionId); } catch (final UncheckedExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof NoSuchSubscriptionException) { throw (NoSuchSubscriptionException) cause; } throw new ServiceTemporarilyUnavailableException("Failed to access subscription cache", cause); } catch (final ExecutionException e) { throw new ServiceTemporarilyUnavailableException("Failed to access subscription cache", e.getCause()); } }
Source:
<code>public DefaultAuditRecordService(AuditRecordRepository auditRecordRepository, ObjectMapper objectMapper) { <START> super(); <END> Assert.notNull(auditRecordRepository, "auditRecordRepository must not be null."); Assert.notNull(auditRecordRepository, "objectMapper must not be null."); this.auditRecordRepository = auditRecordRepository; this.objectMapper = objectMapper; }</code><technical_language>Is a specific reason for this</technical_language>

Target:
public DefaultAuditRecordService(AuditRecordRepository auditRecordRepository, ObjectMapper objectMapper) { Assert.notNull(auditRecordRepository, "auditRecordRepository must not be null."); Assert.notNull(objectMapper, "objectMapper must not be null."); this.auditRecordRepository = auditRecordRepository; this.objectMapper = objectMapper; }
Source:
<code>static Object checkAndCopy(Object val, boolean copy) { if (val == null) { } else if (val instanceof Number && !(val instanceof BigDecimal)) { } else if (val instanceof Boolean) { } else if (val instanceof String) { } else if (val instanceof CharSequence) { val = val.toString(); } else if (val instanceof JsonObject) { if (copy) { val = ((JsonObject) val).copy(); } } else if (val instanceof JsonArray) { if (copy) { val = ((JsonArray) val).copy(); } } else if (val instanceof Map) { if (copy) { val = (new JsonObject((Map)val)).copy(); } else { val = new JsonObject((Map)val); } } else if (val instanceof List) { if (copy) { val = (new JsonArray((List)val)).copy(); } else { val = new JsonArray((List)val); } } else if (val instanceof byte[]) { val = Base64.getEncoder().encodeToString((byte[])val); } else if (val instanceof Instant) { <START> val = OffsetDateTime.ofInstant((Instant) val, ZoneOffset.UTC).format(ISO_OFFSET_DATE_TIME); <END> } else { throw new IllegalStateException("Illegal type in JsonObject: " + val.getClass()); } return val; }</code><technical_language>is this related range PR? some other commits mixed in here</technical_language>

Target:
static Object checkAndCopy(Object val, boolean copy) { if (val == null) { } else if (val instanceof Number && !(val instanceof BigDecimal)) { } else if (val instanceof Boolean) { } else if (val instanceof String) { } else if (val instanceof Character) { } else if (val instanceof CharSequence) { val = val.toString(); } else if (val instanceof JsonObject) { if (copy) { val = ((JsonObject) val).copy(); } } else if (val instanceof JsonArray) { if (copy) { val = ((JsonArray) val).copy(); } } else if (val instanceof Map) { if (copy) { val = (new JsonObject((Map)val)).copy(); } else { val = new JsonObject((Map)val); } } else if (val instanceof List) { if (copy) { val = (new JsonArray((List)val)).copy(); } else { val = new JsonArray((List)val); } } else if (val instanceof byte[]) { val = Base64.getEncoder().encodeToString((byte[])val); } else { throw new IllegalStateException("Illegal type in JsonObject: " + val.getClass()); } return val; }
Source:
<code>public OWLOntology loadOntology(IRI ontologyIRI, String catalogPath) throws IOException { OWLOntology ontology; File catalogFile = null; if (catalogPath != null) { catalogFile = new File(catalogPath); if (!catalogFile.isFile()) { throw new IOException(String.format(fileDoesNotExistError, catalogPath)); } } try { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); if (catalogFile != null) { manager.setIRIMappers(Sets.newHashSet(new CatalogXmlIRIMapper(catalogFile))); } <START> if (ontologyIRI.toString().endsWith("gz")) { <END> ontology = loadCompressedOntology(new URL(ontologyIRI.toString()), catalogPath); } else { ontology = manager.loadOntologyFromOntologyDocument(ontologyIRI); } } catch (OWLOntologyCreationException e) { throw new IOException(e); } return ontology; }</code><technical_language>I this for .gz</technical_language>

Target:
public OWLOntology loadOntology(IRI ontologyIRI, String catalogPath) throws IOException { OWLOntology ontology; File catalogFile = null; if (catalogPath != null) { catalogFile = new File(catalogPath); if (!catalogFile.isFile()) { throw new IOException(String.format(fileDoesNotExistError, catalogPath)); } } try { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); if (catalogFile != null) { manager.setIRIMappers(Sets.newHashSet(new CatalogXmlIRIMapper(catalogFile))); } if (ontologyIRI.toString().endsWith(".gz")) { ontology = loadCompressedOntology(new URL(ontologyIRI.toString()), catalogPath); } else { ontology = manager.loadOntologyFromOntologyDocument(ontologyIRI); } } catch (OWLOntologyCreationException e) { throw new IOException(e); } return ontology; }
Source:
<code>public Builder setDefaultHandshakeMode(String defaultHandshakeMode) { if (config.serverOnly) { throw new IllegalStateException("default handshake modes are not supported for server only!"); } if (defaultHandshakeMode != null) { <START> if (!defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_AUTO) <END> && !defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_NONE)) { throw new IllegalArgumentException( "default handshake mode must be either \"" + DtlsEndpointContext.HANDSHAKE_MODE_AUTO + "\" or \"" + DtlsEndpointContext.HANDSHAKE_MODE_NONE + "\"!"); } } config.defaultHandshakeMode = defaultHandshakeMode; return this; }</code><technical_language>if forbid set DefaultHandshakeMode if serverOnly is set, forbid set serverOnly if DefaultHanshake mode is set. (If chose raise error all, I ok too)</technical_language>

Target:
public Builder setDefaultHandshakeMode(String defaultHandshakeMode) { if (config.serverOnly != null && config.serverOnly) { throw new IllegalStateException("default handshake modes are not supported for server only!"); } if (defaultHandshakeMode != null) { if (!defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_AUTO) && !defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_NONE)) { throw new IllegalArgumentException( "default handshake mode must be either \"" + DtlsEndpointContext.HANDSHAKE_MODE_AUTO + "\" or \"" + DtlsEndpointContext.HANDSHAKE_MODE_NONE + "\"!"); } } config.defaultHandshakeMode = defaultHandshakeMode; return this; }
Source:
<code>public List<? extends Module> getJacksonModules() { return ImmutableList.of( new SimpleModule(getClass().getSimpleName()) .registerSubtypes( new NamedType(MaterializedViewSupervisorSpec.class, "view"), <START> new NamedType(DerivativeDataSourceMetadata.class, "view") <END> ) ); }</code><technical_language>Please more specific JSON type names</technical_language>

Target:
public List<? extends Module> getJacksonModules() { return ImmutableList.of( new SimpleModule(getClass().getSimpleName()) .registerSubtypes( new NamedType(MaterializedViewSupervisorSpec.class, "derivativeDataSource"), new NamedType(DerivativeDataSourceMetadata.class, "derivativeDataSource") ) ); }
Source:
<code>private static void addMethod(FieldNode fieldNode, BlockStatement body, ClassNode type) { int visibility = ACC_PUBLIC; if (fieldNode.isStatic()) visibility |= ACC_STATIC; String propName = MetaClassHelper.capitalize(fieldNode.getName().substring(1)); fieldNode.getDeclaringClass().addMethod("get" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); if (ClassHelper.boolean_TYPE.equals(type)) { <START> fieldNode.getDeclaringClass().addMethod("is" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); <END> } }</code><technical_language>stmt(callThisX("get" + propName)) instead of body. give a slightly smaller class</technical_language>

Target:
private static void addMethod(FieldNode fieldNode, BlockStatement body, ClassNode type) { int visibility = ACC_PUBLIC; if (fieldNode.isStatic()) visibility |= ACC_STATIC; String propName = MetaClassHelper.capitalize(fieldNode.getName().substring(1)); fieldNode.getDeclaringClass().addMethod("get" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); if (ClassHelper.boolean_TYPE.equals(type)) { fieldNode.getDeclaringClass().addMethod("is" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, stmt(callThisX("get" + propName))); } }