auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public static GameObject getDefaultEntity(int id, EntityType type) <END> { throw new UnsupportedOperationException("Not implemented"); }</code><technical_language>is idea this</technical_language>

Target:
public static GameObject getDefaultEntity(int id, EntityType type) { switch (type) { case WALL: return new Wall(id); case ENEMY_CHARACTER: GameObject enemy = new BoDCharacter(id, new Point2D(0, 0), 50, 50, 0, defaultImages.get(EntityType.ENEMY_CHARACTER)); return enemy; } return null; }
Source:
<code>private CompareResult compareComponentParam( int valueStartPos, int valueLength, @NonNull byte[] inboundValue ) { if (( byteArray[valueStartPos] == '{' && byteArray[valueStartPos + 1] == '}' ) || ( inboundValue.length == 0 )) { return null; } for (int i = 0; i < inboundValue.length; i++) { if (byteArray[valueStartPos + i] == '{') { for (int j = valueLength - 1, k = inboundValue.length - 1; j >= 0; j--, k--) { if (byteArray[valueStartPos + j] == '}') { byte[] placeholderValue = new byte[k - i + 1]; byte[] placeholder = new byte[(valueStartPos + j) - (valueStartPos + i) - 1]; System.arraycopy(inboundValue, i, placeholderValue, 0, placeholderValue.length); System.arraycopy(byteArray, valueStartPos + i + 1, placeholder, 0, placeholder.length); return new CompareResult( <START> new StringBuilder(placeholderValue.length + placeholder.length + 1) <END> .append(new String(placeholder)).append(MATCH_PARAM_DIVIDER_CHAR) .append(new String(placeholderValue)).toString(), false); } if (byteArray[valueStartPos + j] != inboundValue[k]) { return null; } } } if (byteArray[valueStartPos + i] != inboundValue[i]) { return null; } } return new CompareResult("", false); }</code><technical_language>nit: Ide warning stringbuilder replaced string</technical_language>

Target:
private CompareResult compareComponentParam( int valueStartPos, int valueLength, @NonNull byte[] inboundValue ) { if (( byteArray[valueStartPos] == '{' && byteArray[valueStartPos + 1] == '}' ) || ( inboundValue.length == 0 )) { return null; } for (int i = 0; i < inboundValue.length; i++) { if (byteArray[valueStartPos + i] == '{') { for (int j = valueLength - 1, k = inboundValue.length - 1; j >= 0; j--, k--) { if (byteArray[valueStartPos + j] == '}') { byte[] placeholderValue = new byte[k - i + 1]; byte[] placeholder = new byte[(valueStartPos + j) - (valueStartPos + i) - 1]; System.arraycopy(inboundValue, i, placeholderValue, 0, placeholderValue.length); System.arraycopy(byteArray, valueStartPos + i + 1, placeholder, 0, placeholder.length); return new CompareResult( new String(placeholder) + MATCH_PARAM_DIVIDER_CHAR + new String(placeholderValue), false); } if (byteArray[valueStartPos + j] != inboundValue[k]) { return null; } } } if (byteArray[valueStartPos + i] != inboundValue[i]) { return null; } } return new CompareResult("", false); }
Source:
<code>public void handleResponse(StunMessageEvent evt) { TransactionID transactionID = getTransactionID(); <START> logger.log(Level.FINE, "handleResponse tid " + transactionID); <END> if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE)) { cancel(); } responseCollector.processResponse( new StunResponseEvent( stackCallback, evt.getRawMessage(), (Response) evt.getMessage(), request, transactionID)); }</code><technical_language>change this a direct call tweaking (logger.fine i think?)</technical_language>

Target:
public void handleResponse(StunMessageEvent evt) { TransactionID transactionID = getTransactionID(); logger.fine("handleResponse tid " + transactionID); if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE)) { cancel(); } responseCollector.processResponse( new StunResponseEvent( stackCallback, evt.getRawMessage(), (Response) evt.getMessage(), request, transactionID)); }
Source:
<code>protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { if (req.getQueryString() == null || req.getQueryString().isEmpty()) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); if (deniedActions.contains(params.get("a"))) { rsp.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if (params.get("a").equals(PROJECT_LIST_ACTION)) { rsp.sendRedirect(req.getContextPath() + "/#" + PageLinks.ADMIN_PROJECTS + "?filter=" + <START> params.get("pf") + <END> "/"); return; } String name = params.get("p"); if (name == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (name.endsWith(".git")) { name = name.substring(0, name.length() - 4); } final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible() && !project.isOwner()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { if (userProvider.get().isIdentifiedUser()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { rsp.sendRedirect(getLoginRedirectUrl(req)); } return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { CacheHeaders.setNotCacheable(rsp); exec(req, rsp, project); } finally { repo.close(); } }</code><technical_language>I need URL encode pf cram redirect</technical_language>

Target:
protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { if (req.getQueryString() == null || req.getQueryString().isEmpty()) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); if (deniedActions.contains(params.get("a"))) { rsp.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if (params.get("a").equals(PROJECT_LIST_ACTION)) { rsp.sendRedirect(req.getContextPath() + "/#" + PageLinks.ADMIN_PROJECTS + "?filter=" + Url.encode(params.get("pf") + "/")); return; } String name = params.get("p"); if (name == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (name.endsWith(".git")) { name = name.substring(0, name.length() - 4); } final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible() && !project.isOwner()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { if (userProvider.get().isIdentifiedUser()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { rsp.sendRedirect(getLoginRedirectUrl(req)); } return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { CacheHeaders.setNotCacheable(rsp); exec(req, rsp, project); } finally { repo.close(); } }
Source:
<code>public Receive createReceive() { return receiveBuilder() .match(Tick.class, message -> { <START> _periodicMetrics.recordCounter("JobExecutorActor-ticks", 1); <END> final JobRepository<T> repo = _jobRef.getRepository(_injector); final Optional<Job<T>> job = _jobRef.get(_injector); if (!job.isPresent()) { LOGGER.warn() .setMessage("no such job") .addData("jobRef", _jobRef) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final UUID id = _jobRef.getJobId(); final Organization org = _jobRef.getOrganization(); final Optional<Instant> lastRun = repo.getLastRun(id, org); final Optional<Instant> nextRun = job.get().getSchedule().nextRun(lastRun); if (!nextRun.isPresent()) { LOGGER.info() .setMessage("job has no more scheduled runs") .addData("jobRef", _jobRef) .addData("schedule", job.get().getSchedule()) .addData("lastRun", lastRun) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final Instant now = _clock.instant(); timers().startSingleTimer("TICK", Tick.INSTANCE, timeUntilNextTick(now, nextRun.get())); if (nextRun.get().isBefore(now)) { execute(repo, org, job.get(), nextRun.get()); } }) .build(); }</code><technical_language>nit: metric names generally lower-snake-case in this codebase</technical_language>

Target:
public Receive createReceive() { return receiveBuilder() .match(Tick.class, message -> { _periodicMetrics.recordCounter("job-executor-actor-ticks", 1); final JobRepository<T> repo = _jobRef.getRepository(_injector); final Optional<Job<T>> job = _jobRef.get(_injector); if (!job.isPresent()) { LOGGER.warn() .setMessage("no such job") .addData("jobRef", _jobRef) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final UUID id = _jobRef.getJobId(); final Organization org = _jobRef.getOrganization(); final Optional<Instant> lastRun = repo.getLastRun(id, org); final Optional<Instant> nextRun = job.get().getSchedule().nextRun(lastRun); if (!nextRun.isPresent()) { LOGGER.info() .setMessage("job has no more scheduled runs") .addData("jobRef", _jobRef) .addData("schedule", job.get().getSchedule()) .addData("lastRun", lastRun) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } if (!_clock.instant().isBefore(nextRun.get())) { executeAndScheduleNextTick(repo, org, job.get(), nextRun.get()); } else { scheduleNextTick(nextRun.get()); } }) .build(); }
Source:
<code>public void testKeepsSorting() { <START> preferencesService.getPreferences().getGameListSorting().setAll(FXCollections.observableArrayList( <END> new Pair<>("hostColumn", SortType.DESCENDING) )); instance.initializeGameTable(FXCollections.observableArrayList( GameBuilder.create().defaultValues().get(), GameBuilder.create().defaultValues().state(GameStatus.CLOSED).get() )); assertThat(instance.gamesTable.getSortOrder(), hasSize(1)); assertThat(instance.gamesTable.getSortOrder().get(0).getId(), is("hostColumn")); assertThat(instance.gamesTable.getSortOrder().get(0).getSortType(), is(SortType.DESCENDING)); }</code><technical_language>a varargs signature of setAll need wrap FXCollections.observableArrayList :)</technical_language>

Target:
public void testKeepsSorting() { preferencesService.getPreferences().getGameListSorting().setAll(new Pair<>("hostColumn", SortType.DESCENDING)); instance.initializeGameTable(FXCollections.observableArrayList( GameBuilder.create().defaultValues().get(), GameBuilder.create().defaultValues().state(GameStatus.CLOSED).get() )); assertThat(instance.gamesTable.getSortOrder(), hasSize(1)); assertThat(instance.gamesTable.getSortOrder().get(0).getId(), is("hostColumn")); assertThat(instance.gamesTable.getSortOrder().get(0).getSortType(), is(SortType.DESCENDING)); }
Source:
<code>public void start(ComponentContext context) { super.start(context); ClusterService clusterService = Framework.getService(ClusterService.class); <START> if (clusterService != null && clusterService.isEnabled()) { <END> String nodeId = clusterService.getNodeId(); invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); started = true; }</code><technical_language>ClusterService is a basic runtime service is required pubsub for invalidations of caches, directories repositories. deployed cache service</technical_language>

Target:
public void start(ComponentContext context) { super.start(context); ClusterService clusterService = Framework.getService(ClusterService.class); if (clusterService.isEnabled()) { String nodeId = clusterService.getNodeId(); invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); started = true; }
Source:
<code>private String toString(String separator, boolean braces) { if (size == 0) return braces ? "{}" : ""; StringBuilder buffer = new StringBuilder(32); if (braces) buffer.append('{'); K[] keyTable = this.keyTable; V[] valueTable = this.valueTable; int i = keyTable.length; for(int j = i; j > 0; j--) { K key = keyTable[j]; if (key != null) { <START> buffer.append(separator); <END> buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); } } if (braces) buffer.append('}'); return buffer.toString(); }</code><technical_language>This toString() needs refactoring, new code is semantically equivalent. I in code, separator is added element, is added in new code. Please confirm is case, if so, fix it</technical_language>

Target:
private String toString(String separator, boolean braces) { if (size == 0) return braces ? "{}" : ""; StringBuilder buffer = new StringBuilder(32); if (braces) buffer.append('{'); int i = keyTable.length; while (i-- > 0) { K key = keyTable[i]; if (key == null) continue; buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); break; } while (i-- > 0) { K key = keyTable[i]; if (key == null) continue; buffer.append(separator); buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); } if (braces) buffer.append('}'); return buffer.toString(); }
Source:
<code>private void zoom(@NonNull TimeGraphEntry entry, ITmfStateSystem ss, @NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState, @NonNull IProgressMonitor monitor) { List<ITimeEvent> eventList = getEventList(entry, ss, fullStates, prevFullState, monitor); if (eventList != null) { for (ITimeEvent event : eventList) { if (monitor.isCanceled()) { return; } <START> applyResults(() -> { <END> entry.addZoomedEvent(event); }); } } for (ITimeGraphEntry child : entry.getChildren()) { if (monitor.isCanceled()) { return; } if (child instanceof TimeGraphEntry) { zoom((TimeGraphEntry) child, ss, fullStates, prevFullState, monitor); } } }</code><technical_language>I wrap for-loop in applyResults()</technical_language>

Target:
private void zoom(@NonNull TimeGraphEntry entry, ITmfStateSystem ss, @NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState, @NonNull IProgressMonitor monitor) { List<ITimeEvent> eventList = getEventList(entry, ss, fullStates, prevFullState, monitor); if (eventList != null) { applyResults(() -> { for (ITimeEvent event : eventList) { if (monitor.isCanceled()) { return; } entry.addZoomedEvent(event); } }); } for (ITimeGraphEntry child : entry.getChildren()) { if (monitor.isCanceled()) { return; } if (child instanceof TimeGraphEntry) { zoom((TimeGraphEntry) child, ss, fullStates, prevFullState, monitor); } } }
Source:
<code><START> public static long wait(int wait, Callable<Void> callable) throws ExecutionException, WaitTimeoutException { <END> long now = System.currentTimeMillis(); if (wait > 0) { try { FutureTask<Void> task = new FutureTask<>(callable); task.run(); task.get(wait, TimeUnit.SECONDS); } catch (@SuppressWarnings("unused") InterruptedException e) { Thread.currentThread().interrupt(); } catch (@SuppressWarnings("unused") TimeoutException e) { throw new WaitTimeoutException("timed out waiting for execution to complete", delta(now)); } } return delta(now); }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Refactor this method throw checked exception instead of: java.util.concurrent.ExecutionException, io.fabric8.maven.docker.wait.WaitTimeoutException [![rule](<LINK_2>](<LINK_1></technical_language>

Target:
public static long wait(int wait, Callable<Void> callable) throws ExecutionException, WaitTimeoutException { long now = System.currentTimeMillis(); if (wait > 0) { try { FutureTask<Void> task = new FutureTask<>(callable); task.run(); task.get(wait, TimeUnit.SECONDS); } catch (@SuppressWarnings("unused") InterruptedException e) { Thread.currentThread().interrupt(); } catch (@SuppressWarnings("unused") TimeoutException e) { throw new WaitTimeoutException("timed out waiting for execution to complete: " + e, delta(now)); } } return delta(now); }
Source:
<code>public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (UncheckedExecutionException ue) { <START> to.setPublicUri(from.getUrl()); <END> } catch (CacheLoader.InvalidCacheLoadException e) { } if (to.getContentMetadata() != null && to.getContentMetadata().getContentType() != null && to.getContentMetadata().getContentType().equals("application/directory")) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } to.setSize(from.getContentMetadata().getContentLength()); AccessTier tier = from.getTier(); to.setTier((tier != null ? tier : AccessTier.HOT).toTier()); return to; }</code><technical_language>work? java } catch (Exception ex) { InsufficientAccessRightsException iare = Throwables2.getFirstThrowableOfType(ex, InsufficientAccessRightsException.class); if (iare == null) throw ex; // Propagate other uncaught exceptions to.setPublicUri(from.getUrl()); // handle exception gracefully }</technical_language>

Target:
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (Exception ex) { InsufficientAccessRightsException iare = Throwables2.getFirstThrowableOfType(ex, InsufficientAccessRightsException.class); if (iare == null) throw ex; } if (to.getContentMetadata() != null && to.getContentMetadata().getContentType() != null && to.getContentMetadata().getContentType().equals("application/directory")) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } to.setSize(from.getContentMetadata().getContentLength()); AccessTier tier = from.getTier(); to.setTier((tier != null ? tier : AccessTier.HOT).toTier()); return to; }
Source:
<code>public void run() { logger.info("running: " + testID); try { String experimentID = testModelDAO.getRunningExperiment(testID); if (experimentID != null) { <START> experimentManagerService.abortBenchFlowExperiment(experimentID); <END> } } catch (BenchFlowTestIDDoesNotExistException e) { } }</code><technical_language>want get ACK execution of operation, is complex control behaviour of distributed system</technical_language>

Target:
public void run() { logger.info("running: " + testID); try { String experimentID = testModelDAO.getRunningExperiment(testID); if (experimentID != null) { experimentManagerService.abortBenchFlowExperiment(experimentID); } } catch (BenchFlowTestIDDoesNotExistException e) { e.printStackTrace(); } }
Source:
<code>public boolean equals(final Object o) { if (o == null) { return false; } if (o == this) { return true; } <START> if (this.getClass() != o.getClass()) { <END> return false; } final SnmpV3User that = (SnmpV3User)o; return Objects.equals(getAuthPassPhrase(), that.getAuthPassPhrase()) && Objects.equals(getAuthProtocol(), that.getAuthProtocol()) && Objects.equals(getEngineId(), that.getEngineId()) && Objects.equals(getPrivPassPhrase(), that.getPrivPassPhrase()) && Objects.equals(getPrivProtocol(), that.getPrivProtocol()); }</code><technical_language>instanceof instead? getClass() a problem, issues a class is proxied subclassed</technical_language>

Target:
public boolean equals(final Object o) { if (o == null) { return false; } if (o == this) { return true; } if (o instanceof SnmpV3User) { final SnmpV3User that = (SnmpV3User)o; return Objects.equals(getAuthPassPhrase(), that.getAuthPassPhrase()) && Objects.equals(getAuthProtocol(), that.getAuthProtocol()) && Objects.equals(getEngineId(), that.getEngineId()) && Objects.equals(getPrivPassPhrase(), that.getPrivPassPhrase()) && Objects.equals(getPrivProtocol(), that.getPrivProtocol()); } else { return false; } }
Source:
<code>public void setup(OperatorContext context) { LOG.debug("APPLICATION PATH FROM PYTHON OPERATOR" + (String)context.getValue(DAGContext.APPLICATION_PATH)); this.pythonWorkerContext.setup(); this.pythonWorkerProxy = new PythonWorkerProxy<>(this.serializedFunction); int port = NetworkUtils.findAvaliablePort(); <START> this.server = new GatewayServer(this.pythonWorkerProxy, port); <END> this.py4jListener = new PythonGenericOperator.PythonGatewayServerListenser(this.server, this.pythonWorkerContext); this.server.addListener(this.py4jListener); this.server.start(true); int pythonServerStartAttempts = 5; while (!this.py4jListener.isPythonServerStarted() && !this.pythonWorkerProxy.isFunctionEnabled() && pythonServerStartAttempts > 0) { try { Thread.sleep(5000L); LOG.debug("Waiting for Python Worker Registration"); --pythonServerStartAttempts; } catch (InterruptedException var9) { var9.printStackTrace(); } } if (this.pythonWorkerProxy.isWorkerRegistered()) { this.pythonWorkerProxy.setFunction(this.operationType.getType()); } if (!this.py4jListener.isPythonServerStarted()) { LOG.error("Python server could not be started"); } }</code><technical_language>exists a race condition while finding free port. try this for number of times if GatewayServer creation fails</technical_language>

Target:
public void setup(OperatorContext context) { LOG.debug("Application path from Python Operator: ", (String)context.getValue(DAGContext.APPLICATION_PATH)); server.setup(); }
Source:
<code>public void createNewComponent () { Engine engine = new Engine(); ComponentD componentD = engine.createComponent(ComponentD.class); <START> assertNotEquals(componentD, null); <END> }</code><technical_language>I is assertNotNull(), please do that</technical_language>

Target:
public void createNewComponent () { Engine engine = new Engine(); ComponentD componentD = engine.createComponent(ComponentD.class); assertNotNull(componentD); }
Source:
<code>public static String version(Class<?> weldClass) { String version = null; String timestamp = null; <START> InputStream in = weldClass.getResourceAsStream(BUILD_PROPERTIES_FILE); <END> try { if (in != null) { try { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } finally { in.close(); } } } catch (IOException e) { } if (version == null) { Package pkg = weldClass.getPackage(); if (pkg == null) { throw new IllegalArgumentException("Package can not be null"); } version = pkg.getSpecificationVersion(); timestamp = pkg.getImplementationVersion(); } return version(version, timestamp); }</code><technical_language>This simplified try-with-resources</technical_language>

Target:
public static String version(Class<?> weldClass) { String version = null; String timestamp = null; try (InputStream in = weldClass.getResourceAsStream(BUILD_PROPERTIES_FILE)) { if (in != null) { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } } catch (IOException e) { } if (version == null) { Package pkg = weldClass.getPackage(); if (pkg == null) { throw new IllegalArgumentException("Package can not be null"); } version = pkg.getSpecificationVersion(); timestamp = pkg.getImplementationVersion(); } return version(version, timestamp); }
Source:
<code>private Runnable createValidatableRunnable(CheckType checkType, IJobManager manager) { return () -> { try { long runningExpensiveJobs = Arrays.asList(manager.find(CheckType.EXPENSIVE.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningNormalJobs = Arrays.asList(manager.find(CheckType.NORMAL.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningFastJobs = Arrays.asList(manager.find(CheckType.FAST.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long allRunningJobs = runningExpensiveJobs + runningFastJobs + runningNormalJobs; assertTrue(allRunningJobs <= VALIDATION_THREAD_COUNT); if (CheckType.EXPENSIVE == checkType) { assertTrue(runningExpensiveJobs == MAXIMUM_AMOUNT_OF_RUNNING_EXPENSIVE_JOBS); } if (CheckType.NORMAL == checkType) { assertTrue(runningNormalJobs <= MAXIMUM_AMOUNT_OF_RUNNING_NORMAL_JOBS); } <START> Thread.sleep(500); <END> } catch (InterruptedException e) { e.printStackTrace(); } }; }</code><technical_language>nice configure this hardcoded 500 ms timeout based CheckType, simulate cost more accurately</technical_language>

Target:
private Runnable createValidatableRunnable(CheckType checkType, IJobManager manager) { long runTime = checkType == CheckType.EXPENSIVE ? EXPENSIVE_JOB_RUNTIME : CheckType.NORMAL == checkType ? NORMAL_JOB_RUNTIME : FAST_JOB_RUNTIME; return () -> { try { long runningExpensiveJobs = Arrays.asList(manager.find(CheckType.EXPENSIVE.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningNormalJobs = Arrays.asList(manager.find(CheckType.NORMAL.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningFastJobs = Arrays.asList(manager.find(CheckType.FAST.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long allRunningJobs = runningExpensiveJobs + runningFastJobs + runningNormalJobs; assertTrue(allRunningJobs <= VALIDATION_THREAD_COUNT); System.out.println( String.format( "Number of expensive ones are [%d], number of normal ones [%d], number of fast ones [%d]", runningExpensiveJobs, runningNormalJobs, runningFastJobs) ); if (CheckType.EXPENSIVE == checkType) { assertTrue(runningExpensiveJobs <= MAXIMUM_AMOUNT_OF_RUNNING_EXPENSIVE_JOBS); } if (CheckType.NORMAL == checkType) { assertTrue(runningNormalJobs <= MAXIMUM_AMOUNT_OF_RUNNING_NORMAL_JOBS); } Thread.sleep(runTime); } catch (InterruptedException e) { throw new RuntimeException(e); } }; }
Source:
<code>static Stream<Set<Integer>> generatePartitions(int totalNodes) { <START> checkArgument(totalNodes >= 2, "totalNodes must be greater than or equal to 2"); <END> Set<Integer> numbers = IntStream.range(0, totalNodes) .boxed() .collect(toImmutableSet()); return Sets.powerSet(numbers).stream() .filter(subSet -> subSet.contains(0)) .filter(subSet -> subSet.size() < numbers.size()); }</code><technical_language>For consistency sake, sense > 1 here</technical_language>

Target:
static Set<Set<Integer>> generatePartitions(int totalNodes) { checkArgument(totalNodes > 1, "totalNodes must be greater than 1"); Set<Integer> numbers = IntStream.range(0, totalNodes) .boxed() .collect(toImmutableSet()); return powerSet(numbers).stream() .filter(subSet -> subSet.contains(0)) .filter(subSet -> subSet.size() < numbers.size()) .collect(toImmutableSet()); }
Source:
<code><START> public void setUp() throws Exception { <END> productReleaseDao = mock(ProductReleaseDao.class); productReleaseSdcDao = mock(ProductReleaseSdcDao.class); metadataDao = mock (MetadataDao.class); attributeDao = mock (AttributeDao.class); claudiaData = mock (ClaudiaData.class); manager = new ProductReleaseManagerImpl(); manager.setAttributeDao(attributeDao); manager.setMetadataDao(metadataDao); manager.setProductReleaseDao(productReleaseDao); manager.setProductReleaseSdcDao(productReleaseSdcDao); productReleasePM = new ProductRelease("product", "version"); productReleaseSDC = new ProductRelease("product", "version"); Metadata metadata1 = new Metadata("key1", "value1"); productReleasePM.addMetadata(metadata1); productReleaseSDC.addMetadata(metadata1); Metadata metadata2 = new Metadata("key2", "value2"); productReleasePM.addMetadata(metadata2); productReleaseSDC.addMetadata(metadata2); productReleaseSDC.addMetadata(metadata_diff); when(productReleaseSdcDao.load(eq("product"), eq("version"), any(ClaudiaData.class))).thenReturn(productReleaseSDC); when(productReleaseDao.load(any(String.class))).thenReturn(productReleasePM); when(metadataDao.create(any(Metadata.class))).thenReturn(metadata_diff); }</code><technical_language>In this method, I wrong indentation of lines</technical_language>

Target:
public void setUp() throws Exception { productReleaseDao = mock(ProductReleaseDao.class); productReleaseSdcDao = mock(ProductReleaseSdcDao.class); metadataDao = mock (MetadataDao.class); attributeDao = mock (AttributeDao.class); claudiaData = mock (ClaudiaData.class); manager = new ProductReleaseManagerImpl(); manager.setAttributeDao(attributeDao); manager.setMetadataDao(metadataDao); manager.setProductReleaseDao(productReleaseDao); manager.setProductReleaseSdcDao(productReleaseSdcDao); productReleasePM = new ProductRelease("product", "version"); productReleaseSDC = new ProductRelease("product", "version"); Metadata metadata1 = new Metadata("key1", "value1"); productReleasePM.addMetadata(metadata1); productReleaseSDC.addMetadata(metadata1); Metadata metadata2 = new Metadata("key2", "value2"); productReleasePM.addMetadata(metadata2); productReleaseSDC.addMetadata(metadata2); productReleaseSDC.addMetadata(metadata_diff); when(productReleaseSdcDao.load(eq("product"), eq("version"), any(ClaudiaData.class))) .thenReturn(productReleaseSDC); when(productReleaseDao.load(any(String.class))).thenReturn(productReleasePM); when(metadataDao.create(any(Metadata.class))).thenReturn(metadata_diff); when(metadataDao.load(any(String.class))).thenReturn(metadata_diff); }
Source:
<code>public String getLabel() { if (tagType == ReaderTagType.DEFAULT) { return getTagTitle(); <START> } else if (isTagAlphaNumeric(tagDisplayName)) { <END> return tagDisplayName.toLowerCase(); } else if (hasTagTitle()) { return getTagTitle(); } else { return getTagDisplayName(); } }</code><technical_language>instead of accessing tagDisplayName, getter? This allow remove parameter in isTagAlphaNumeric()</technical_language>

Target:
public String getLabel() { if (tagType == ReaderTagType.DEFAULT) { return getTagTitle(); } else if (isTagDisplayNameAlphaNumeric()) { return getTagDisplayName().toLowerCase(); } else if (hasTagTitle()) { return getTagTitle(); } else { return getTagDisplayName(); } }
Source:
<code>protected BreakpointContainer[] getContainers(IBreakpoint breakpoint) { if (isShowingGroups()) { IAdaptable[] categories = fOrganizers[0].getCategories(breakpoint); if (categories == null || categories.length == 0) { categories = OtherBreakpointCategory.getCategories(fOrganizers[0]); } BreakpointContainer[] containers = new BreakpointContainer[categories.length]; int index = 0; for (Object <START> fElement : <END> fElements) { BreakpointContainer container = (BreakpointContainer)fElement; for (IAdaptable category : categories) { if (container.getCategory().equals(category)) { containers[index] = container; index++; } } } return containers; } return null; }</code><technical_language>rename element</technical_language>

Target:
protected BreakpointContainer[] getContainers(IBreakpoint breakpoint) { if (isShowingGroups()) { IAdaptable[] categories = fOrganizers[0].getCategories(breakpoint); if (categories == null || categories.length == 0) { categories = OtherBreakpointCategory.getCategories(fOrganizers[0]); } BreakpointContainer[] containers = new BreakpointContainer[categories.length]; int index = 0; for (Object element : fElements) { BreakpointContainer container = (BreakpointContainer)element; for (IAdaptable category : categories) { if (container.getCategory().equals(category)) { containers[index] = container; index++; } } } return containers; } return null; }
Source:
<code>public Map<String, Set<String>> getPrincipalRoles(PID target) { List<PID> path = getPidPath(target); Map<String, Set<String>> inheritedPrincRoles = new HashMap<>(); Set<String> patronPrincipals = null; <START> int depth = 0; <END> for (; depth < path.size(); depth++) { PID pathPid = path.get(depth); if (depth < 2) { Map<String, Set<String>> objectPrincipalRoles = objectAclFactory.getPrincipalRoles(pathPid); mergePrincipalRoles(inheritedPrincRoles, objectPrincipalRoles); } else { if (inheritedPrincRoles.isEmpty()) { return inheritedPrincRoles; } if (patronPrincipals == null) { patronPrincipals = getPatronPrincipals(inheritedPrincRoles.keySet()); } if (patronPrincipals.size() == 0) { return inheritedPrincRoles; } removeRevokedPatronRoles(pathPid, inheritedPrincRoles, patronPrincipals); } } if (depth == 1) { Set<String> roles = new HashSet<>(); roles.add(UserRole.canViewOriginals.getPropertyString()); inheritedPrincRoles.put("everyone", roles); } return inheritedPrincRoles; }</code><technical_language>I int values stored meaningful constants for code readability. So, e.g., int depth = ADMIN_UNIT if (depth >= COLLECTION). interested in knowing others' opinions this, though. @lfarrell, do a preference</technical_language>

Target:
public Map<String, Set<String>> getPrincipalRoles(PID target) { List<PID> path = getPidPath(target); Map<String, Set<String>> inheritedPrincRoles = new HashMap<>(); Set<String> patronPrincipals = null; int depth = 0; for (; depth < path.size(); depth++) { PID pathPid = path.get(depth); if (depth < CONTENT_STARTING_DEPTH) { Map<String, Set<String>> objectPrincipalRoles = objectAclFactory.getPrincipalRoles(pathPid); mergePrincipalRoles(inheritedPrincRoles, objectPrincipalRoles); } else { if (inheritedPrincRoles.isEmpty()) { return inheritedPrincRoles; } if (patronPrincipals == null) { patronPrincipals = getPatronPrincipals(inheritedPrincRoles.keySet()); } if (patronPrincipals.size() == 0) { return inheritedPrincRoles; } revokedPatronRoles(pathPid, inheritedPrincRoles, patronPrincipals); } } if (depth == UNIT_PATH_DEPTH + 1) { Set<String> roles = new HashSet<>(); roles.add(UserRole.canViewOriginals.getPropertyString()); inheritedPrincRoles.put("everyone", roles); } return inheritedPrincRoles; }
Source:
<code>@Override public void onReady() { Scope scope = currentTraceContext.maybeScope(invocationContext); <START> try { <END> delegate().onReady(); } finally { scope.close(); } }</code><technical_language>if gRPC Java 8 means prefer try/resources in case</technical_language>

Target:
@Override public void onReady() { try (Scope scope = currentTraceContext.maybeScope(invocationContext)) { delegate().onReady(); } }
Source:
<code>private LockResponse lock(LockDescriptor lockDescriptor) { <START> TimelockService timelockService = new LegacyTimelockService(timestampService, lockService, lockClient); <END> LockRequest lockRequest = LockRequest.of(ImmutableSet.of(lockDescriptor), 5_000); return timelockService.lock(lockRequest); }</code><technical_language>Creating a new timelock service time want a lock suspicious (but apparently works!)</technical_language>

Target:
private LockResponse lock(LockDescriptor lockDescriptor) { LockRequest lockRequest = LockRequest.of(ImmutableSet.of(lockDescriptor), 5_000); return timelockService.lock(lockRequest); }
Source:
<code>public PackageBuilder getPackageBuilder() { <START> if (packagingType.equals(MULE_DOMAIN_BUNDLE)) { <END> return new DomainBundlePackageBuilder(); } PackagingOptions options = new PackagingOptions(onlyMuleSources, lightweightPackage, attachMuleSources); return new MulePackageBuilder().withPackagingOptions(options); }</code><technical_language>Please create a PackageBuilderFactory.create(packagingType) in this case create receive a PackagingOptions</technical_language>

Target:
public PackageBuilder getPackageBuilder() { PackagingOptions options = new PackagingOptions(onlyMuleSources, lightweightPackage, attachMuleSources); return PackageBuilderFactory.create(packagingType, options); }
Source:
<code>private CopyCmdAnswer performCopyOfVdi(VolumeInfo volumeInfo, SnapshotInfo snapshotInfo, HostVO hostVO) { String value = _configDao.getValue(Config.PrimaryStorageDownloadWait.toString()); int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), volumeInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); CopyCmdAnswer copyCmdAnswer = null; try { _volumeService.grantAccess(snapshotInfo, hostVO, snapshotInfo.getDataStore()); _volumeService.grantAccess(volumeInfo, hostVO, volumeInfo.getDataStore()); Map<String, String> srcDetails = getSnapshotDetails(snapshotInfo); copyCommand.setOptions(srcDetails); Map<String, String> destDetails = getVolumeDetails(volumeInfo); copyCommand.setOptions2(destDetails); copyCmdAnswer = (CopyCmdAnswer)_agentMgr.send(hostVO.getId(), copyCommand); } catch (Exception ex) { <START> throw new CloudRuntimeException(ex.getMessage()); <END> } finally { try { _volumeService.revokeAccess(snapshotInfo, hostVO, snapshotInfo.getDataStore()); } catch (Exception ex) { s_logger.debug(ex.getMessage(), ex); } try { _volumeService.revokeAccess(volumeInfo, hostVO, volumeInfo.getDataStore()); } catch (Exception ex) { s_logger.debug(ex.getMessage(), ex); } } return copyCmdAnswer; }</code><technical_language>Please add contextual information copy VDI operation error message assist operational debugging</technical_language>

Target:
private CopyCmdAnswer performCopyOfVdi(VolumeInfo volumeInfo, SnapshotInfo snapshotInfo, HostVO hostVO) { String value = _configDao.getValue(Config.PrimaryStorageDownloadWait.toString()); int primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); CopyCommand copyCommand = new CopyCommand(snapshotInfo.getTO(), volumeInfo.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); CopyCmdAnswer copyCmdAnswer = null; try { _volumeService.grantAccess(snapshotInfo, hostVO, snapshotInfo.getDataStore()); _volumeService.grantAccess(volumeInfo, hostVO, volumeInfo.getDataStore()); Map<String, String> srcDetails = getSnapshotDetails(snapshotInfo); copyCommand.setOptions(srcDetails); Map<String, String> destDetails = getVolumeDetails(volumeInfo); copyCommand.setOptions2(destDetails); copyCmdAnswer = (CopyCmdAnswer)_agentMgr.send(hostVO.getId(), copyCommand); } catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) { String msg = "Failed to perform VDI copy : "; LOGGER.warn(msg, ex); throw new CloudRuntimeException(msg + ex.getMessage()); } finally { _volumeService.revokeAccess(snapshotInfo, hostVO, snapshotInfo.getDataStore()); _volumeService.revokeAccess(volumeInfo, hostVO, volumeInfo.getDataStore()); } return copyCmdAnswer; }
Source:
<code>private ListenableFuture<Boolean> get(String key, OutputStream out, boolean actionResult) { <START> boolean foundOnDisk = diskCache.toPath(key, actionResult).exists(); <END> if (foundOnDisk) { return getFromCache(diskCache, key, out, actionResult); } else { return getFromRemoteAndSaveToDisk(key, out, actionResult); } }</code><technical_language>call contains here</technical_language>

Target:
private ListenableFuture<Boolean> get(String key, OutputStream out, boolean actionResult) { boolean foundOnDisk = actionResult ? diskCache.containsActionResult(key) : diskCache.contains(key); if (foundOnDisk) { return getFromCache(diskCache, key, out, actionResult); } else { return getFromRemoteAndSaveToDisk(key, out, actionResult); } }
Source:
<code>private JoinEnumerationResult(Optional<PlanNode> planNode, PlanNodeCostEstimate cost) { <START> this.planNode = requireNonNull(planNode); <END> this.cost = requireNonNull(cost); checkArgument((cost.hasUnknownComponents() || cost.equals(INFINITE_COST)) && !planNode.isPresent() || (!cost.hasUnknownComponents() || !cost.equals(INFINITE_COST)) && planNode.isPresent(), "planNode should be present if and only if cost is known"); }</code><technical_language>add a message</technical_language>

Target:
private JoinEnumerationResult(Optional<PlanNode> planNode, PlanNodeCostEstimate cost) { this.planNode = requireNonNull(planNode, "planNode is null"); this.cost = requireNonNull(cost, "cost is null"); checkArgument((cost.hasUnknownComponents() || cost.equals(INFINITE_COST)) && !planNode.isPresent() || (!cost.hasUnknownComponents() || !cost.equals(INFINITE_COST)) && planNode.isPresent(), "planNode should be present if and only if cost is known"); }
Source:
<code>public String toString() { return Objects.toStringHelper(this).add("uuid", uuid).add("description", description).add("osFamily", osFamily) .add("osVersion", osVersion).add("size", size).add("is64bit", is64bit).add("loginUser", loginUser) <START> .toString(); <END> }</code><technical_language>[minor] Do want show nulls here, omitNullValues</technical_language>

Target:
public String toString() { return Objects.toStringHelper(this).omitNullValues().add("uuid", uuid).add("description", description) .add("osFamily", osFamily).add("osVersion", osVersion).add("size", size).add("is64bit", is64bit) .add("loginUser", loginUser).toString(); }
Source:
<code>public PlanNodeCostEstimate calculateCost(PlanNode planNode, Lookup lookup, Session session, Map<Symbol, Type> types) { <START> return UNKNOWN_COST; <END> }</code><technical_language>Wow, pretty useless squash this commit "Implement CostCalculators"</technical_language>

Target:
public PlanNodeCostEstimate calculateCost(PlanNode planNode, Lookup lookup, Session session, Map<Symbol, Type> types) { CostEstimator costEstimator = new CostEstimator( session, types, lookup, numberOfNodes); return planNode.accept(costEstimator, null); }
Source:
<code>private void disposeServices() { <START> HashMap<Class<?>, Object> copy = new HashMap<>(services); <END> Set<Entry<Class<?>, Object>> entrySet = copy.entrySet(); for (Entry<Class<?>, Object> entry : entrySet) { if (entry.getValue() instanceof IDisposable) { IDisposable iDisposable = (IDisposable) entry.getValue(); SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { iDisposable.dispose(); } @Override public void handleException(Throwable ex) { WorkbenchPlugin .log(StatusUtil.newStatus(IStatus.ERROR, "Error while disposing: " + iDisposable, ex)); } }); } services.remove(entry.getKey()); } }</code><technical_language>ConcurrentHashMap, I avoid this copy. ConcurrentHashMap#values() is backed map, services added in middle of iteration show in iteration. If fact, iterator remove() services dispose of them</technical_language>

Target:
private void disposeServices() { Iterator<Entry<Class<?>, Object>> iterator = services.entrySet().iterator(); while (iterator.hasNext()) { Entry<Class<?>, Object> entry = iterator.next(); if (entry.getValue() instanceof IDisposable) { IDisposable iDisposable = (IDisposable) entry.getValue(); SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { iDisposable.dispose(); } @Override public void handleException(Throwable ex) { WorkbenchPlugin .log(StatusUtil.newStatus(IStatus.ERROR, "Error while disposing: " + iDisposable.getClass().getName(), ex)); } }); } iterator.remove(); } }
Source:
<code>private String updateSchema(byte[] byteContent) { String result = null; if (byteContent != null) { boolean modified = false; try { Document document = getSchemaDocument(byteContent); modified = handleUUIDElement(document); if (modified) { result = Util.formatXsdSource(Util.nodeToString(document)); } } catch (Exception e) { <START> LOG.error(e.getMessage(), e); <END> } } return result; }</code><technical_language>Please add a self-defined message instead of e.getMessage()</technical_language>

Target:
private String updateSchema(byte[] byteContent) { String result = null; if (byteContent != null) { boolean modified = false; try { Document document = getSchemaDocument(byteContent); modified = handleUUIDElement(document); if (modified) { result = Util.formatXsdSource(Util.nodeToString(document)); } } catch (Exception e) { LOG.error("Failed to update data model schema.", e); } } return result; }
Source:
<code>public void removeUnusedTypes_EncapsulatingTypes_Test() { final String parentType = "com.spectralogic.Test.Parent"; final String childType = "com.spectralogic.Test.Child"; final String grandchildType = "com.spectralogic.Test.Grandchild"; final Ds3Type parentDs3Type = new Ds3Type( parentType, ImmutableList.of(new Ds3Element("Child", childType, null, null)), null); final Ds3Type childDs3Type = new Ds3Type( childType, ImmutableList.of( new Ds3Element("Grandchild", grandchildType, null, null)), null); final Ds3Type grandchildDs3Type = new Ds3Type( grandchildType, null, null); final ImmutableList<Ds3Request> requests = ImmutableList.of( <START> new Ds3Request(null, null, null, null, null, null, null, null, null, false, <END> null, ImmutableList.of( new Ds3Param(null, "java.util.UUID"), new Ds3Param(null, parentType)), null)); final ImmutableMap<String, Ds3Type> typeMap = ImmutableMap.of( parentType, parentDs3Type, childType, childDs3Type, grandchildType, grandchildDs3Type, "com.spectralogic.Test.UnusedType", new Ds3Type(null, null, null)); final ImmutableMap<String, Ds3Type> result = removeUnusedTypes(typeMap, requests); assertThat(result.size(), is(3)); assertTrue(result.containsKey(parentType)); assertTrue(result.containsKey(childType)); assertTrue(result.containsKey(grandchildType)); }</code><technical_language>add some new constructors this cleaner..</technical_language>

Target:
public void removeUnusedTypes_EncapsulatingTypes_Test() { final String parentType = "com.spectralogic.Test.Parent"; final String childType = "com.spectralogic.Test.Child"; final String grandchildType = "com.spectralogic.Test.Grandchild"; final Ds3Type parentDs3Type = createDs3TypeTestData( parentType, createDs3ElementListTestData("Child", childType)); final Ds3Type childDs3Type = createDs3TypeTestData( childType, createDs3ElementListTestData("Grandchild", grandchildType)); final Ds3Type grandchildDs3Type = createDs3TypeTestData(grandchildType); final ImmutableList<Ds3Request> requests = ImmutableList.of( createDs3RequestTestData( false, ImmutableList.of( createDs3ParamTestData("java.util.UUID"), new Ds3Param(null, parentType)), null)); final ImmutableMap<String, Ds3Type> typeMap = ImmutableMap.of( parentType, parentDs3Type, childType, childDs3Type, grandchildType, grandchildDs3Type, "com.spectralogic.Test.UnusedType", createEmptyDs3Type()); final ImmutableMap<String, Ds3Type> result = removeUnusedTypes(typeMap, requests); assertThat(result.size(), is(3)); assertTrue(result.containsKey(parentType)); assertTrue(result.containsKey(childType)); assertTrue(result.containsKey(grandchildType)); }
Source:
<code>public ActionResult execute() { String studentId = getNonNullRequestParamValue(Const.ParamsNames.STUDENT_ID); StudentProfileAttributes studentProfile = logic.getStudentProfile(studentId); if (studentProfile == null) { <START> studentProfile = StudentProfileAttributes.builder(studentId).build(); <END> } StudentProfile output = new StudentProfile(studentProfile); return new JsonResult(output); }</code><technical_language>This get else's student profile? a check if is userInfo's ID</technical_language>

Target:
public ActionResult execute() { String studentId = getNonNullRequestParamValue(Const.ParamsNames.STUDENT_ID); if (!studentId.equals(userInfo.id) && !isMasqueradeMode()) { return new JsonResult("You are not authorized to view this student's profile.", HttpStatus.SC_FORBIDDEN); } StudentProfileAttributes studentProfile = logic.getStudentProfile(studentId); String name = logic.getAccount(studentId).name; if (studentProfile == null) { studentProfile = StudentProfileAttributes.builder(studentId).build(); } StudentProfile output = new StudentProfile(name, studentProfile); return new JsonResult(output); }