auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public ResponseEntity<String> getDocumentContent(@PathVariable("name") String documentName) throws SdkClientException, AmazonServiceException, IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(this.bucketName, documentName); S3Object documentObject = this.s3Client.getObject(getObjectRequest); InputStream inputStream = documentObject.getObjectContent(); <START> String documentContent = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8); <END> return ResponseEntity.ok().body(documentContent); }</code><technical_language>Images binary, decoded UTF-8, is text. Minimum change return ResponseEntity<byte[]>, load image memory, stream client. a Spring MVC options for streaming data endpoint</technical_language>

Target:
public ResponseEntity<StreamingResponseBody> getDocumentContent( @PathVariable("name") String documentName) throws SdkClientException { GetObjectRequest getObjectRequest = new GetObjectRequest(this.bucketName, documentName); S3Object documentObject = this.s3Client.getObject(getObjectRequest); ObjectMetadata objectMetadata = documentObject.getObjectMetadata(); HttpHeaders headers = new HttpHeaders(); headers.set(HttpHeaders.ACCEPT_RANGES, "bytes"); headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; preview-type=application/html"); headers.set(HttpHeaders.CONTENT_TYPE, objectMetadata.getContentType()); headers.set(HttpHeaders.ETAG, objectMetadata.getETag()); headers.setCacheControl("max-age=86401"); headers.setContentLength(objectMetadata.getContentLength()); StreamingResponseBody responseBody = outputStream -> { try (InputStream inputStream = documentObject.getObjectContent()) { int numberOfBytes; byte[] data = new byte[1024]; while ((numberOfBytes = inputStream.read(data, 0, data.length)) != -1) { outputStream.write(data, 0, numberOfBytes); } } }; CacheControl cacheControl = CacheControl.maxAge(24, TimeUnit.HOURS) .noTransform() .cachePublic(); return ResponseEntity.ok().headers(headers) .cacheControl(cacheControl) .body(responseBody); }
Source:
<code>private void dropMessage(AddressedTuple tuple, JCQueue queue) { ++dropCount; queue.recordMsgDrop(); <START> LOG.warn("Dropping message as overflow threshold has reached for Q = {}. OverflowCount = {}. Total Drop Count= {}, Dropped Message : {}", queue.getName(), queue.getOverflowCount(), dropCount, tuple.toString()); <END> }</code><technical_language>nit: tuple.toString() is needed, logging do for you, this is a warn log called matter</technical_language>

Target:
private void dropMessage(AddressedTuple tuple, JCQueue queue) { ++dropCount; queue.recordMsgDrop(); LOG.warn("Dropping message as overflow threshold has reached for Q = {}. OverflowCount = {}. Total Drop Count= {}, Dropped Message : {}", queue.getName(), queue.getOverflowCount(), dropCount, tuple); }
Source:
<code>private static void waitForCrateFramework() { Awaitility.await().atMost(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollInterval(1, TimeUnit.SECONDS).until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { Framework fw = cluster.getMaster().getState().getFramework("crate-mesos"); if (fw != null) { crateMesosFrameworkHostIp = cluster.getAgentStateInfo(fw.getHostname()).getString("hostname"); <START> int status = Unirest.head( <END> String.format("http://%s:%d/cluster", crateMesosFrameworkHostIp, API_PORT)).asJson().getStatus(); return status == 200; } else { return false; } } }); }</code><technical_language>if API is Unirest throws exception</technical_language>

Target:
private static void waitForCrateFramework() { Awaitility.await().atMost(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS) .pollInterval(1, TimeUnit.SECONDS).until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { Framework fw = cluster.getMaster().getState().getFramework("crate-mesos"); int status = 0; if (fw != null) { crateMesosFrameworkHostIp = cluster.getAgentStateInfo(fw.getHostname()).getString("hostname"); try { status = Unirest.head( String.format("http://%s:%d/cluster", crateMesosFrameworkHostIp, API_PORT)).asJson().getStatus(); } catch (UnirestException e) { } return status == 200; } return false; } }); }
Source:
<code>final protected void interrupted() { onInterrupted(); <START> if (!previous.isRunning()) { <END> previous.start(); } }</code><technical_language>reason this is check InjectedCommand</technical_language>

Target:
final protected void interrupted() { onInterrupted(); if (previous != null && (!previous.isRunning() || previous.isCanceled())) { previous.start(); } }
Source:
<code>public String getLabel() { <START> return "Drop Association as DestroyLinkAction"; <END> }</code><technical_language>Missing NLS</technical_language>

Target:
public String getLabel() { return Messages.AssociationToDestroyLinkActionDropStrategy_Label; }
Source:
<code>private void showInputSurface() { if (mInputSurface == null) { mInputSurface = <START> mService.makeSurfaceBuilder( <END> mService.mRoot.getDisplayContent(mDisplayContent.getDisplayId()).getSession()) .setContainerLayer() .setName("Drag and Drop Input Consumer").build(); } final InputWindowHandle h = getInputWindowHandle(); if (h == null) { Slog.w(TAG_WM, "Drag is in progress but there is no " + "drag window handle."); return; } mTransaction.show(mInputSurface); mTransaction.setInputWindowInfo(mInputSurface, h); mTransaction.setLayer(mInputSurface, Integer.MAX_VALUE); mTmpClipRect.set(0, 0, mDisplaySize.x, mDisplaySize.y); mTransaction.setWindowCrop(mInputSurface, mTmpClipRect); mTransaction.transferTouchFocus(mTransferTouchFromToken, h.token); mTransferTouchFromToken = null; mDisplayContent.reparentToOverlay(mTransaction, mInputSurface); mTransaction.syncInputWindows(); mTransaction.apply(); }</code><technical_language>nit: DisplayContent#makeOverlay</technical_language>

Target:
private void showInputSurface() { if (mInputSurface == null) { mInputSurface = mService.mRoot.getDisplayContent(mDisplayContent.getDisplayId()) .makeOverlay() .setContainerLayer() .setName("Drag and Drop Input Consumer").build(); } final InputWindowHandle h = getInputWindowHandle(); if (h == null) { Slog.w(TAG_WM, "Drag is in progress but there is no " + "drag window handle."); return; } mTransaction.show(mInputSurface); mTransaction.setInputWindowInfo(mInputSurface, h); mTransaction.setLayer(mInputSurface, Integer.MAX_VALUE); mTmpClipRect.set(0, 0, mDisplaySize.x, mDisplaySize.y); mTransaction.setWindowCrop(mInputSurface, mTmpClipRect); mTransaction.transferTouchFocus(mTransferTouchFromToken, h.token); mTransferTouchFromToken = null; mTransaction.syncInputWindows(); mTransaction.apply(); }
Source:
<code>protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { if (context.isResourceServiceRestartAllowed()) { String securityDomainName = context.getCurrentAddressValue(); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException { context.removeService(new SingleSignOnManagerServiceNameProvider(securityDomainName).getServiceName()); context.removeService(new SingleSignOnSessionFactoryServiceNameProvider(securityDomainName).getServiceName()); } <START> }, OperationContext.Stage.RUNTIME); <END> } super.performRemove(context, operation, model); knownApplicationSecurityDomains.remove(context.getCurrentAddressValue()); }</code><technical_language>I realize this fault - I triggering service removal this method (even correctly moving runtime stage). Instead move 2 lines overridden performRuntime(...), additionally calls super implementation, remove service removed ServiceRemoveStepHandler. services security domain removed in step</technical_language>

Target:
protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { super.performRemove(context, operation, model); knownApplicationSecurityDomains.remove(context.getCurrentAddressValue()); }
Source:
<code>public String serializeEntry(List<String> entry) { try { return mapper.writer().writeValueAsString(entry); } catch (JsonProcessingException e) { <START> throw new IllegalArgumentException(e); <END> } }</code><technical_language>this exception thrown / caused user input? If I prefer a checked exception (even if a DevfileException something) unchecked means more about</technical_language>

Target:
public String serializeEntry(List<String> entry) { try { return mapper.writer().writeValueAsString(entry); } catch (JsonProcessingException e) { throw new IllegalStateException( format("Failed to serialize list of strings %s to YAML", entry), e); } }
Source:
<code>public Optional<FieldProjectionExpectations<Float>> getFieldProjectionExpectations() { return Optional.of( new FieldProjectionExpectations<>( <START> 1.001f, 3.0f, 5.1f <END> ) ); }</code><technical_language>for doubles, of negative</technical_language>

Target:
public Optional<FieldProjectionExpectations<Float>> getFieldProjectionExpectations() { return Optional.of( new FieldProjectionExpectations<>( -1.001f, 3.0f, 5.1f ) ); }
Source:
<code>public void testExecute_invalidRecommendedLength_shouldThrowException() { InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1"); FeedbackQuestionAttributes typicalQuestion = logic.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), 1); loginAsInstructor(instructor1ofCourse1.getGoogleId()); String[] param = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_ID, typicalQuestion.getFeedbackQuestionId(), }; FeedbackQuestionUpdateRequest updateRequest = getTypicalTextQuestionUpdateRequest(); FeedbackTextQuestionDetails textQuestionDetails = new FeedbackTextQuestionDetails(); textQuestionDetails.setRecommendedLength(-1); updateRequest.setQuestionDetails(textQuestionDetails); UpdateFeedbackQuestionAction a = getAction(updateRequest, param); assertThrows(InvalidHttpRequestBodyException.class, () -> getJsonResult(a)); assertEquals(typicalQuestion.getQuestionDescription(), logic.getFeedbackQuestion(typicalQuestion.getId()).getQuestionDescription()); <START> assertEquals(null, ((FeedbackTextQuestionDetails) typicalQuestion.getQuestionDetails()) <END> .getRecommendedLength()); }</code><technical_language>this assertNull</technical_language>

Target:
public void testExecute_invalidRecommendedLength_shouldThrowException() { InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1"); FeedbackQuestionAttributes typicalQuestion = logic.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), 1); loginAsInstructor(instructor1ofCourse1.getGoogleId()); String[] param = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_ID, typicalQuestion.getFeedbackQuestionId(), }; FeedbackQuestionUpdateRequest updateRequest = getTypicalTextQuestionUpdateRequest(); FeedbackTextQuestionDetails textQuestionDetails = new FeedbackTextQuestionDetails(); textQuestionDetails.setRecommendedLength(-1); updateRequest.setQuestionDetails(textQuestionDetails); UpdateFeedbackQuestionAction a = getAction(updateRequest, param); assertThrows(InvalidHttpRequestBodyException.class, () -> getJsonResult(a)); assertEquals(typicalQuestion.getQuestionDescription(), logic.getFeedbackQuestion(typicalQuestion.getId()).getQuestionDescription()); assertNull(((FeedbackTextQuestionDetails) typicalQuestion.getQuestionDetails()).getRecommendedLength()); }
Source:
<code>public static String space(int n) { if (n < 1) { return ""; } StringBuilder buf = new StringBuilder(n); for (int i = 0; i < n; i++) { buf.append(" "); } <START> return buf.toString(); <END> }</code><technical_language>call repeat(" ", n)</technical_language>

Target:
public static String space(int n) { return repeat(" ", n); }
Source:
<code>protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Label messageLabel = createMessageArea(composite); Text filterText = createFilterText(composite); <START> CheckboxTreeViewer treeViewer = createTreeViewer(composite); <END> Control buttonComposite = createSelectionButtons(composite); GridData filterData = new GridData(GridData.FILL_HORIZONTAL); filterData.widthHint = convertWidthInCharsToPixels(fWidth); filterText.setLayoutData(filterData); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(fWidth); data.heightHint = convertHeightInCharsToPixels(fHeight); Tree treeWidget = treeViewer.getTree(); treeWidget.setLayoutData(data); treeWidget.setFont(parent.getFont()); if (fIsEmpty) { messageLabel.setEnabled(false); filterText.setEnabled(false); treeWidget.setEnabled(false); buttonComposite.setEnabled(false); } return composite; }</code><technical_language>able FilteredTree a PatternFilter instead</technical_language>

Target:
protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Label messageLabel = createMessageArea(composite); CheckboxTreeViewer treeViewer = createTreeViewer(composite); Control buttonComposite = createSelectionButtons(composite); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(fWidth); data.heightHint = convertHeightInCharsToPixels(fHeight); Tree treeWidget = treeViewer.getTree(); treeWidget.setLayoutData(data); treeWidget.setFont(parent.getFont()); if (fIsEmpty) { messageLabel.setEnabled(false); treeWidget.setEnabled(false); buttonComposite.setEnabled(false); } return composite; }
Source:
<code>public VoltTable[] run(SystemProcedureExecutionContext ctx) { VoltDBInterface voltdb = VoltDB.instance(); OperationMode opMode = voltdb.getMode(); if (ctx.isLowestSiteId() && opMode != OperationMode.PAUSED) { ZooKeeper zk = voltdb.getHostMessenger().getZK(); try { Stat stat; OperationMode zkMode = null; Code code; do { stat = new Stat(); code = Code.OK; try { byte data = zk.getData(VoltZK.operationMode, false, stat); zkMode = data == null ? opMode : OperationMode.valueOf(data); if (zkMode == OperationMode.PAUSED) { break; } stat = zk.setData(VoltZK.operationMode, OperationMode.PAUSED.getBytes(), stat.getVersion()); } catch (BadVersionException ex) { code = ex.code(); } } while (zkMode != OperationMode.PAUSED && code != Code.BADVERSION); m_stat = stat; voltdb.setMode(OperationMode.PAUSED); <START> voltdb.getHostMessenger().pause(); <END> } catch (Exception e) { throw new RuntimeException(e); } } VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA); t.addRow(VoltSystemProcedure.STATUS_OK); return (new VoltTable[] {t}); }</code><technical_language>Shouldnt hostmessenger pause setMode</technical_language>

Target:
public VoltTable[] run(SystemProcedureExecutionContext ctx) { if (ctx.isLowestSiteId()) { VoltDBInterface voltdb = VoltDB.instance(); OperationMode opMode = voltdb.getMode(); if (LOG.isDebugEnabled()) { LOG.debug("voltdb opmode is " + opMode); } ZooKeeper zk = voltdb.getHostMessenger().getZK(); try { Stat stat; OperationMode zkMode = null; Code code; do { stat = new Stat(); code = Code.BADVERSION; try { byte data = zk.getData(VoltZK.operationMode, false, stat); if (LOG.isDebugEnabled()) { LOG.debug("zkMode is " + (zkMode == null ? "(null)" : OperationMode.valueOf(data))); } zkMode = data == null ? opMode : OperationMode.valueOf(data); if (zkMode == PAUSED) { if (LOG.isDebugEnabled()) { LOG.debug("read node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid())); } break; } stat = zk.setData(VoltZK.operationMode, PAUSED.getBytes(), stat.getVersion()); code = Code.OK; zkMode = PAUSED; if (LOG.isDebugEnabled()) { LOG.debug("!WROTE! node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid())); } break; } catch (BadVersionException ex) { code = ex.code(); } } while (zkMode != PAUSED && code == Code.BADVERSION); m_stat = stat; voltdb.getHostMessenger().pause(); voltdb.setMode(PAUSED); } catch (Exception e) { throw new RuntimeException(e); } } VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA); t.addRow(VoltSystemProcedure.STATUS_OK); return (new VoltTable[] {t}); }
Source:
<code>public void dispatchEvent(final Object event, final Dictionary<?,?> serviceProperties) { assert event != null; <START> if (DsfDebugOptions.DEBUG && DsfDebugOptions.DEBUG_SESSION && DsfDebugOptions.DEBUG_SESSION_DISPATCHES) { <END> String msg = new Formatter().format( "%s Dispatching event %s to session %s from thread \"%s\" (%d)", DsfPlugin.getDebugTime(), LoggingUtils.toString(event), LoggingUtils.toString(this), Thread.currentThread().getName(), Thread.currentThread().getId() ).toString(); DsfDebugOptions.trace(msg); } getExecutor().submit(new DsfRunnable() { @Override public void run() { doDispatchEvent(event, serviceProperties);} @Override public String toString() { return "Event: " + event + ", from service " + serviceProperties; } }); }</code><technical_language>DsfDebugOptions... mentioned</technical_language>

Target:
public void dispatchEvent(final Object event, final Dictionary<?,?> serviceProperties) { assert event != null; if (DsfDebugOptions.DEBUG_SESSION_DISPATCHES) { String msg = new Formatter().format( "%s Dispatching event %s to session %s from thread \"%s\" (%d)", DsfPlugin.getDebugTime(), LoggingUtils.toString(event), LoggingUtils.toString(this), Thread.currentThread().getName(), Thread.currentThread().getId() ).toString(); DsfDebugOptions.trace(msg); } getExecutor().submit(new DsfRunnable() { @Override public void run() { doDispatchEvent(event, serviceProperties);} @Override public String toString() { return "Event: " + event + ", from service " + serviceProperties; } }); }
Source:
<code>private static boolean isTrustedProxy(String ip) { boolean isTrusted = false; for (String proxyIp : trustedProxies) { String sanitizedProxyIp = proxyIp.trim(); try { if (!sanitizedProxyIp.isEmpty() && new IpAddressMatcher(sanitizedProxyIp).matches(ip)) { isTrusted = true; break; } } catch (IllegalArgumentException argEx) { <START> LOG.error(argEx); <END> } } return isTrusted; }</code><technical_language>If element in trustedProxies is valid, I consider a constant, unrecoverable issue of class itself. class is unusable then. Hence, I check trusted proxy ips construction time, instead of everytime try it. I guess easiest, robust achieve is switch methods static instance methods, add a constructor performs checks throws exception in case of misconfigurations. This switch prepare for future want construct instances of IpUtils based kinds of trusted proxies. Also, adding a constructor, this switch give a natural place call new IpAddressMatcher trusted proxy ips instantiated matchers in memory. way, nicer heap gc (cf. caching PS2) isTrustedProxy basically called for log line. ~150K/second of them</technical_language>

Target:
private boolean isTrustedProxy(String ip) { boolean isTrusted = false; for (IpAddressMatcher ipAddressMatcher : ipAddressMatcherCache.values()) { if (ipAddressMatcher.matches(ip)) { isTrusted = true; break; } } return isTrusted; }
Source:
<code>public WorkflowResponse execute(WorkflowDTO workflowDTO) throws WorkflowException { if (log.isDebugEnabled()) { log.debug("Executing User SignUp Webservice Workflow for " + workflowDTO.getWorkflowReference()); } String callBackURL = workflowDTO.getCallbackUrl(); String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(workflowDTO.getWorkflowReference()); String message="Approve APIStore signup request done by "+tenantAwareUserName +" from the tenant domain "+workflowDTO.getTenantDomain(); workflowDTO.setWorkflowDescription(message); workflowDTO.setMetadata("TenantUserName", tenantAwareUserName); workflowDTO.setMetadata("TenantDomain", workflowDTO.getTenantDomain()); workflowDTO.setMetadata("workflowExternalRef", workflowDTO.getExternalWorkflowReference()); workflowDTO.setMetadata("callBackURL", callBackURL != null ? callBackURL : "?"); workflowDTO.setProperties("Workflow Process","User Self Sign Up"); <START> <END> super.execute(workflowDTO); return new GeneralWorkflowResponse(); }</code><technical_language>metadata properties needed</technical_language>

Target:
public WorkflowResponse execute(WorkflowDTO workflowDTO) throws WorkflowException { if (log.isDebugEnabled()) { log.debug("Executing User SignUp Webservice Workflow for " + workflowDTO.getWorkflowReference()); } String callBackURL = workflowDTO.getCallbackUrl(); String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(workflowDTO.getWorkflowReference()); String message = "Approve APIStore signup request done by " + tenantAwareUserName + " from the tenant domain " + workflowDTO.getTenantDomain(); workflowDTO.setWorkflowDescription(message); super.execute(workflowDTO); return new GeneralWorkflowResponse(); }
Source:
<code>public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; <START> System.out.println("CORSFilter HTTP Request: " + request.getMethod()); <END> ((HttpServletResponse) servletResponse).addHeader("Access-Control-Allow-Origin", "*"); ((HttpServletResponse) servletResponse).addHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD, PUT, POST"); HttpServletResponse resp = (HttpServletResponse) servletResponse; if (request.getMethod().equals("OPTIONS")) { resp.setStatus(HttpServletResponse.SC_ACCEPTED); return; } filterChain.doFilter(request, servletResponse); }</code><technical_language>logging instead. slf4j logger. Also, add logging in general easier debug later. adding log, aware of usage of log levels. private static final Logger logger = LoggerFactory.getLogger(CORSFilter.class); // code logger.debug("Filtering request: {}", request.getMethod()); // Errors logger.error("Some .... error occurred. someVariable: {}", var, exception);</technical_language>

Target:
public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; logger.debug("CORSFilter HTTP Request: ",request.getMethod()); ((HttpServletResponse) servletResponse).addHeader("Access-Control-Allow-Origin", "*"); ((HttpServletResponse) servletResponse) .addHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD, PUT, POST"); HttpServletResponse resp = (HttpServletResponse) servletResponse; if (request.getMethod().equals("OPTIONS")) { resp.setStatus(HttpServletResponse.SC_ACCEPTED); return; } filterChain.doFilter(request, servletResponse); }
Source:
<code>private static ClientSession doGetSession(MongoDbFactory dbFactory, SessionSynchronization sessionSynchronization) { MongoResourceHolder resourceHolder = (MongoResourceHolder) TransactionSynchronizationManager.getResource(dbFactory); if (resourceHolder != null && (resourceHolder.hasSession() || resourceHolder.isSynchronizedWithTransaction())) { <START> resourceHolder.requested(); <END> if (!resourceHolder.hasSession()) { resourceHolder.setSession(createClientSession(dbFactory)); } return resourceHolder.getSession(); } if (SessionSynchronization.NATIVE.equals(sessionSynchronization)) { return null; } resourceHolder = new MongoResourceHolder(createClientSession(dbFactory), dbFactory); resourceHolder.requested(); resourceHolder.getSession().startTransaction(); TransactionSynchronizationManager .registerSynchronization(new MongoSessionSynchronization(resourceHolder, dbFactory)); resourceHolder.setSynchronizedWithTransaction(true); TransactionSynchronizationManager.bindResource(dbFactory, resourceHolder); return resourceHolder.getSession(); }</code><technical_language>RefCount is incremented access. I increment this access. Otherwise, multiple calls reference underlying resource multiple times reducing refcount</technical_language>

Target:
private static ClientSession doGetSession(MongoDbFactory dbFactory, SessionSynchronization sessionSynchronization) { MongoResourceHolder resourceHolder = (MongoResourceHolder) TransactionSynchronizationManager.getResource(dbFactory); if (resourceHolder != null && (resourceHolder.hasSession() || resourceHolder.isSynchronizedWithTransaction())) { if (!resourceHolder.hasSession()) { resourceHolder.setSession(createClientSession(dbFactory)); } return resourceHolder.getSession(); } if (SessionSynchronization.ON_ACTUAL_TRANSACTION.equals(sessionSynchronization)) { return null; } resourceHolder = new MongoResourceHolder(createClientSession(dbFactory), dbFactory); resourceHolder.getSession().startTransaction(); TransactionSynchronizationManager .registerSynchronization(new MongoSessionSynchronization(resourceHolder, dbFactory)); resourceHolder.setSynchronizedWithTransaction(true); TransactionSynchronizationManager.bindResource(dbFactory, resourceHolder); return resourceHolder.getSession(); }
Source:
<code>protected String getSearchPattern() { String user_defined_pattern = QueryHelper.getConstraint(getUriInfo(), "", modelType); return user_defined_pattern.equals("Users : ") ? user_defined_pattern + USERS_SEARCH_PATTERN : <START> user_defined_pattern + AND_SEARCH_PATTERN + USERS_SEARCH_PATTERN; <END> }</code><technical_language>split, allow AD users in this context</technical_language>

Target:
private String getSearchPattern() { String user_defined_pattern = QueryHelper.getConstraint(getUriInfo(), "", modelType); return user_defined_pattern.equals("Users : ") ? user_defined_pattern + USERS_SEARCH_PATTERN : user_defined_pattern + AND_SEARCH_PATTERN + USERS_SEARCH_PATTERN; }
Source:
<code><START> public String getBuildStartedMessage(Run build) { <END> return null; }</code><technical_language>changes binary compatible <LINK_0></technical_language>

Target:
public String getBuildStartedMessage(Run build) { if (build instanceof AbstractBuild && thisOverrides("getBuildStartedMessage", AbstractBuild.class)) { return getBuildStartedMessage((AbstractBuild)build); } return null; }
Source:
<code>protected void appendAsColumnName(Path<?> path, boolean precededByDot) { if (path.getAnnotatedElement().isAnnotationPresent(Column.class)) { <START> SQLTemplates templates = getTemplates(); <END> Column column = path.getAnnotatedElement().getAnnotation(Column.class); if (!column.name().isEmpty()) { append(templates.quoteIdentifier(column.name(), precededByDot)); } else { super.appendAsColumnName(path, precededByDot); } } else { super.appendAsColumnName(path, precededByDot); } }</code><technical_language>templates in branch of if block, _could_ move in there</technical_language>

Target:
protected void appendAsColumnName(Path<?> path, boolean precededByDot) { if (path.getAnnotatedElement().isAnnotationPresent(Column.class)) { Column column = path.getAnnotatedElement().getAnnotation(Column.class); if (!column.name().isEmpty()) { append(getTemplates().quoteIdentifier(column.name(), precededByDot)); } else { super.appendAsColumnName(path, precededByDot); } } else { super.appendAsColumnName(path, precededByDot); } }
Source:
<code>public void shouldParseTheManifestsItCreates() throws IOException { File actual = ManifestUtils.createClasspathJarFile("/some/path/foo.jar" + File.pathSeparator +"/some/path/"); assertThat(ManifestUtils.readClasspathManifest(actual)) <START> .containsExactly(new File("/some/path/foo.jar"), new File("/some/path/")); <END> }</code><technical_language>Expecting: <[D:\some\path\foo.jar, D:\some\path]> (and in order): <[D:\some\path\foo.jar, D:\some\path]> some elements found: <[D:\some\path\foo.jar, D:\some\path]> others expected: <[D:\some\path\foo.jar, D:\some\path]> I run this locally actual is C:\some\... while expected is \some\.... I output is slightly misleading in failure is. utility is telling if objects match Objects.areEqual(..., ...) is basically o1.equals(o2) test passes for I change code to: .containsExactly(new File("/some/path/foo.jar").getAbsoluteFile(), new File("/some/path/").getAbsoluteFile()); I test linux respond</technical_language>

Target:
public void shouldParseTheManifestsItCreates() throws IOException { File actual = ManifestUtils.createClasspathJarFile("some/path/foo.jar" + File.pathSeparator + "some/path/"); assertThat(ManifestUtils.readClasspathManifest(actual)) .containsExactly( new File("some/path/foo.jar").getAbsoluteFile(), new File("some/path/").getAbsoluteFile()); }
Source:
<code>public COREEnvelopeRealTimeResponse realTimeRequest(COREEnvelopeRealTimeRequest msg, AssertionType assertion, NhinTargetSystemType targetSystem, NhincConstants.GATEWAY_API_LEVEL apiLevel) { COREEnvelopeRealTimeResponse response; try { String url = proxyHelper.getUrlFromTargetSystemByGatewayAPILevel(targetSystem, NhincConstants.NHIN_CORE_X12DS_REALTIME_SECURED_SERVICE_NAME, apiLevel); ServicePortDescriptor<AdapterCORETransactionPortType> portDescriptor = new NhinCORE_X12DSRealTimeServicePortDescriptor(); CONNECTClient<AdapterCORETransactionPortType> client = getCONNECTClientSecured(portDescriptor, assertion, url, targetSystem.getHomeCommunity().getHomeCommunityId(), NhincConstants.NHIN_CORE_X12DS_REALTIME_SECURED_SERVICE_NAME); client.enableMtom(); response = (COREEnvelopeRealTimeResponse) client.invokePort(AdapterCORETransactionPortType.class, "realTimeRequest", msg); } catch (Exception ex) { LOG.error("Error calling realTimeRequest: " + ex.getMessage(), ex); response = new COREEnvelopeRealTimeResponse(); <START> response.setErrorMessage(NhincConstants.CORE_X12DS_ACK_ERROR_MSG); <END> response.setErrorCode(NhincConstants.CORE_X12DS_ACK_ERROR_CODE); } return response; }</code><technical_language>error values null right now. waiting decide be? reflect some sort of connection error</technical_language>

Target:
public COREEnvelopeRealTimeResponse realTimeRequest(COREEnvelopeRealTimeRequest msg, AssertionType assertion, NhinTargetSystemType targetSystem, NhincConstants.GATEWAY_API_LEVEL apiLevel) { COREEnvelopeRealTimeResponse response; try { String url = proxyHelper.getUrlFromTargetSystemByGatewayAPILevel(targetSystem, NhincConstants.NHIN_CORE_X12DS_REALTIME_SECURED_SERVICE_NAME, apiLevel); ServicePortDescriptor<AdapterCORETransactionPortType> portDescriptor = new NhinCORE_X12DSRealTimeServicePortDescriptor(); CONNECTClient<AdapterCORETransactionPortType> client = getCONNECTClientSecured(portDescriptor, assertion, url, targetSystem.getHomeCommunity().getHomeCommunityId(), NhincConstants.NHIN_CORE_X12DS_REALTIME_SECURED_SERVICE_NAME); response = (COREEnvelopeRealTimeResponse) client.invokePort(AdapterCORETransactionPortType.class, "realTimeRequest", msg); } catch (Exception ex) { LOG.error("Error calling realTimeRequest: " + ex.getMessage(), ex); response = new COREEnvelopeRealTimeResponse(); response.setErrorMessage(NhincConstants.CORE_X12DS_ACK_ERROR_MSG); response.setErrorCode(NhincConstants.CORE_X12DS_ACK_ERROR_CODE); } return response; }
Source:
<code>public void clear() { <START> if(layoutContent != null) { <END> FormsElementWrapperWidgetUtil.clear(this); layoutContent = null; } formContent.clear(); layoutGenerator.clear(); }</code><technical_language>suggestion if (layoutContent != null) {</technical_language>

Target:
public void clear() { if (layoutContent != null) { wrapperWidgetUtil.clear(this); layoutContent = null; } formContent.clear(); layoutGenerator.clear(); }
Source:
<code>public PreparedAttachment(Attachment attachment, String attachmentsDir, long length, AttachmentStreamFactory attachmentStreamFactory) throws AttachmentException { this.attachment = attachment; this.tempFile = new File(attachmentsDir, "temp" + UUID.randomUUID()); InputStream attachmentInStream = null; OutputStream tempFileOutStream = null; MessageDigest calculateSha1 = null; int totalRead = 0; try { attachmentInStream = attachment.getInputStream(); tempFileOutStream = attachmentStreamFactory.getOutputStream(this.tempFile, Attachment.Encoding.Plain); calculateSha1 = MessageDigest.getInstance("SHA-1"); int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; int bytesRead; while ((bytesRead = attachmentInStream.read(buffer)) != -1) { calculateSha1.update(buffer, 0, bytesRead); tempFileOutStream.write(buffer, 0, bytesRead); totalRead += bytesRead; } } catch (IOException e) { logger.log(Level.WARNING, "Problem reading from input or writing to output stream ", e); throw new AttachmentNotSavedException(e); } catch (NoSuchAlgorithmException e) { logger.log(Level.WARNING, "Problem calculating SHA1 for attachment stream ", e); throw new AttachmentNotSavedException(e); } finally { IOUtils.closeQuietly(attachmentInStream); IOUtils.closeQuietly(tempFileOutStream); } if (this.attachment.encoding == Attachment.Encoding.Plain) { this.length = totalRead; <START> this.encodedLength = 0; <END> } else { this.length = length; this.encodedLength = totalRead; } this.sha1 = calculateSha1.digest(); }</code><technical_language>nice a constant for this, e.g., NO_ENCODED_LENGTH</technical_language>

Target:
public PreparedAttachment(Attachment attachment, String attachmentsDir, long length, AttachmentStreamFactory attachmentStreamFactory) throws AttachmentException { this.attachment = attachment; this.tempFile = new File(attachmentsDir, "temp" + UUID.randomUUID()); InputStream attachmentInStream = null; OutputStream tempFileOutStream = null; MessageDigest calculateSha1 = null; int totalRead = 0; try { attachmentInStream = attachment.getInputStream(); tempFileOutStream = attachmentStreamFactory.getOutputStream(this.tempFile, Attachment.Encoding.Plain); calculateSha1 = MessageDigest.getInstance("SHA-1"); int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; int bytesRead; while ((bytesRead = attachmentInStream.read(buffer)) != -1) { calculateSha1.update(buffer, 0, bytesRead); tempFileOutStream.write(buffer, 0, bytesRead); totalRead += bytesRead; } } catch (IOException e) { logger.log(Level.WARNING, "Problem reading from input or writing to output stream ", e); throw new AttachmentNotSavedException(e); } catch (NoSuchAlgorithmException e) { logger.log(Level.WARNING, "Problem calculating SHA1 for attachment stream ", e); throw new AttachmentNotSavedException(e); } finally { IOUtils.closeQuietly(attachmentInStream); IOUtils.closeQuietly(tempFileOutStream); } if (this.attachment.encoding == Attachment.Encoding.Plain) { this.length = totalRead; this.encodedLength = NO_ENCODED_LENGTH; } else { this.length = length; this.encodedLength = totalRead; } this.sha1 = calculateSha1.digest(); }
Source:
<code>private void applyRefactoring(CheWorkspaceEdit workspaceEdit) { view.close(); WorkspaceEdit edit = new WorkspaceEdit(); edit.setChanges(workspaceEdit.getChanges()); edit.setResourceChanges(new LinkedList<>()); for (ResourceChange resourceChange : workspaceEdit.getResourceChanges()) { edit.getResourceChanges().add(Either.forLeft(resourceChange)); <START> } <END> applyWorkspaceEditAction.applyWorkspaceEdit(edit); setEditorFocus(); }</code><technical_language>Out of curiosity...I thought sending WorkspaceChange wire work? changed</technical_language>

Target:
private void applyRefactoring(CheWorkspaceEdit workspaceEdit) { view.close(); applyWorkspaceEditAction.applyWorkspaceEdit(workspaceEdit); setEditorFocus(); }
Source:
<code>public void testGetModulesByClass() { Map<String, IAnalysisModule> modules = fTrace.getAnalysisModules(); assertTrue(modules.isEmpty()); <START> fTrace.openTrace(); <END> modules = fTrace.getAnalysisModules(); assertFalse(modules.isEmpty()); Map<String, TestAnalysis> testModules = fTrace.getAnalysisModules(TestAnalysis.class); assertFalse(testModules.isEmpty()); for (Entry<String, IAnalysisModule> module : modules.entrySet()) { if (module.getValue() instanceof TestAnalysis) { assertTrue(testModules.containsKey(module.getKey())); } } }</code><technical_language>I intermittently get test timeouts testGetModulesByClass(), this happens, single test time out. I a feeling fTrace.openTrace() potential mess things. individual test modify class fields relevant other tests. This a trace instance here</technical_language>

Target:
public void testGetModulesByClass() { TmfTraceStub trace = (TmfTraceStub) TmfTestTrace.E_TEST_10K.getTrace(); Map<String, IAnalysisModule> modules = trace.getAnalysisModules(); boolean modulesEmpty = modules.isEmpty(); trace.openTrace(); modules = trace.getAnalysisModules(); Map<String, TestAnalysis> testModules = trace.getAnalysisModules(TestAnalysis.class); TmfTestTrace.A_TEST_10K.dispose(); assertTrue(modulesEmpty); assertFalse(modules.isEmpty()); assertFalse(testModules.isEmpty()); for (Entry<String, IAnalysisModule> module : modules.entrySet()) { if (module.getValue() instanceof TestAnalysis) { assertTrue(testModules.containsKey(module.getKey())); } } }
Source:
<code>public static CompressedLongsIndexedSupplier fromByteBuffer(ByteBuffer buffer, ByteOrder order) { ByteBuffer bufferToUse = buffer.asReadOnlyBuffer(); byte versionFromBuffer = bufferToUse.get(); if (versionFromBuffer == LZF_VERSION || versionFromBuffer == version) { final int totalSize = bufferToUse.getInt(); final int sizePer = bufferToUse.getInt(); CompressedObjectStrategy.CompressionStrategy compression = CompressedObjectStrategy.CompressionStrategy.LZF; CompressionFactory.LongEncodingFormat encoding = CompressionFactory.DEFAULT_LONG_ENCODING; if (versionFromBuffer == version) { byte compressionId = bufferToUse.get(); if (compressionId >= (byte) 0xFE) { compression = CompressedObjectStrategy.CompressionStrategy.forId(compressionId); } else { <START> compression = CompressedObjectStrategy.CompressionStrategy.forId((byte) (compressionId + 126)); <END> encoding = CompressionFactory.LongEncodingFormat.forId(bufferToUse.get()); } } Supplier<IndexedLongs> supplier = CompressionFactory.getLongSupplier( totalSize, sizePer, bufferToUse, order, encoding, compression ); return new CompressedLongsIndexedSupplier( totalSize, buffer, supplier ); } throw new IAE("Unknown version[%s]", versionFromBuffer); }</code><technical_language>126 a constant (maybe in CompressionStrategy?) some function converts compression ID representations</technical_language>

Target:
public static CompressedLongsIndexedSupplier fromByteBuffer(ByteBuffer buffer, ByteOrder order) { byte versionFromBuffer = buffer.get(); if (versionFromBuffer == LZF_VERSION || versionFromBuffer == version) { final int totalSize = buffer.getInt(); final int sizePer = buffer.getInt(); CompressedObjectStrategy.CompressionStrategy compression = CompressedObjectStrategy.CompressionStrategy.LZF; CompressionFactory.LongEncodingFormat encoding = CompressionFactory.LEGACY_LONG_ENCODING_FORMAT; if (versionFromBuffer == version) { byte compressionId = buffer.get(); if (CompressionFactory.hasEncodingFlag(compressionId)) { encoding = CompressionFactory.LongEncodingFormat.forId(buffer.get()); compressionId = CompressionFactory.clearEncodingFlag(compressionId); } compression = CompressedObjectStrategy.CompressionStrategy.forId(compressionId); } Supplier<IndexedLongs> supplier = CompressionFactory.getLongSupplier( totalSize, sizePer, buffer.asReadOnlyBuffer(), order, encoding, compression ); return new CompressedLongsIndexedSupplier( totalSize, sizePer, buffer, supplier, compression, encoding ); } throw new IAE("Unknown version[%s]", versionFromBuffer); }
Source:
<code>public void partOpened(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (isCEditor(part)) { CEditor editor = (CEditor) part; if (reconciler == null) { reconciler = new CodanCReconciler(); } if (postSaveListener == null) { postSaveListener = new IPostSaveListener() { @Override public void saved(ITranslationUnit translationUnit, IProgressMonitor monitor) { processResource(translationUnit.getResource(), CheckerLaunchMode.RUN_ON_FILE_SAVE); } }; } <START> reconciler.install(editor); <END> editor.addPostSaveListener(postSaveListener); IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); processResource(resource, CheckerLaunchMode.RUN_ON_FILE_OPEN); } }</code><technical_language>Move line 55 code related reconciler stays together</technical_language>

Target:
public void partOpened(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (isCEditor(part)) { CEditor editor = (CEditor) part; if (reconciler == null) { reconciler = new CodanCReconciler(); } reconciler.install(editor); if (postSaveListener == null) { postSaveListener = new IPostSaveListener() { @Override public void saved(ITranslationUnit translationUnit, IProgressMonitor monitor) { processResource(translationUnit.getResource(), CheckerLaunchMode.RUN_ON_FILE_SAVE); } }; } editor.addPostSaveListener(postSaveListener); IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); processResource(resource, CheckerLaunchMode.RUN_ON_FILE_OPEN); } }
Source:
<code>public void testAutoFlushIsAppliedDuringQueryExecution() throws Exception { Query query = session.createQuery( "from Hypothesis" ); assertQuery( session, 8, query ); Hypothesis hypothesis = new Hypothesis(); hypothesis.setId( "29" ); hypothesis.setDescription( "In the morning it's darker than outside" ); hypothesis.setPosition( 29 ); session.persist( hypothesis ); <START> if ( EnumSet.of( GridModule.MONGODB, GridModule.NEO4J ).contains( TestHelper.getCurrentModule() ) ) { <END> assertQuery( session, query, 9, "Auto-flush should be performed prior to query execution" ); } else { assertQuery( session, query, 8, "Auto-flush should not be reflected by queries executed via Hibernate Search" ); } session.delete( hypothesis ); }</code><technical_language>I thought notion of "module" is needed really, tests skipped / controlled dialect datastore provider</technical_language>

Target:
public void testAutoFlushIsAppliedDuringQueryExecution() throws Exception { Query query = session.createQuery( "from Hypothesis" ); assertQuery( session, 8, query ); Hypothesis hypothesis = new Hypothesis(); hypothesis.setId( "29" ); hypothesis.setDescription( "In the morning it's darker than outside" ); hypothesis.setPosition( 29 ); session.persist( hypothesis ); if ( EnumSet.of( MONGODB, NEO4J ).contains( TestHelper.getCurrentDialectType() ) ) { assertQuery( session, query, 9, "Auto-flush should be performed prior to query execution" ); } else { assertQuery( session, query, 8, "Auto-flush should not be reflected by queries executed via Hibernate Search" ); } session.delete( hypothesis ); }
Source:
<code>public EventData(ByteBuffer body, Context context) { Objects.requireNonNull(body, "'body' cannot be null."); <START> <END> this.body = body; this.properties = new HashMap<>(); this.systemProperties = new SystemProperties(Collections.emptyMap()); this.context = context; }</code><technical_language>Objects.requireNotNull(context);</technical_language>

Target:
public EventData(ByteBuffer body, Context context) { Objects.requireNonNull(body, "'body' cannot be null."); Objects.requireNonNull(body, "'context' cannot be null."); this.body = body; this.properties = new HashMap<>(); this.systemProperties = new SystemProperties(Collections.emptyMap()); this.context = context; }
Source:
<code>public void testToHeader() throws ParseException { final ImmutableList<Request> allRequests = ImmutableList.of( RequestConverter.toRequest(Ds3ModelFixtures.createBucketRequest(), new Ds3DocSpecImpl( ImmutableMap.of(), ImmutableMap.of())), RequestConverter.toRequest(Ds3ModelFixtures.deleteBucketRequest(), new Ds3DocSpecImpl( ImmutableMap.of(), ImmutableMap.of())), RequestConverter.toRequest(Ds3ModelFixtures.getBucketsRequest(), <START> new Ds3DocSpecImpl( <END> ImmutableMap.of(), ImmutableMap.of()))); final ImmutableList<Enum> allEnums = ImmutableList.of( new Enum("TestEnum", ImmutableList.of( "TestEnumValue1", "TestEnumValue2")), new Enum("TestEnum2", ImmutableList.of( "TestEnumValue3", "TestEnumValue4"))); final ImmutableList<Struct> allStructs = ImmutableList.of( new Struct("testStruct1", ImmutableList.of( new StructMember(new PrimitiveType("int", false), "structMember1"), new StructMember(new PrimitiveType("ds3_str", true), "structMember2"))), new Struct("testStruct2", "marshallStruct2", ImmutableList.of( new StructMember(new PrimitiveType("int", false), "structMember3")), false, true, false, false)); final Header testHeader = HeaderConverter.toHeader(allEnums, allStructs, allRequests); assertEquals(testHeader.getEnums(), allEnums); assertEquals(testHeader.getRequests(), allRequests); assertEquals(testHeader.getStructs(), allStructs); }</code><technical_language>Ds3DocSpecEmptyImpl here. Also, is reason creating 3 doc-specs instead of re-using one</technical_language>

Target:
public void testToHeader() throws ParseException { final Ds3DocSpec testDocSpec = new Ds3DocSpecEmptyImpl(); final ImmutableList<Request> allRequests = ImmutableList.of( RequestConverter.toRequest(Ds3ModelFixtures.createBucketRequest(), testDocSpec), RequestConverter.toRequest(Ds3ModelFixtures.deleteBucketRequest(), testDocSpec), RequestConverter.toRequest(Ds3ModelFixtures.getBucketsRequest(), testDocSpec)); final ImmutableList<Enum> allEnums = ImmutableList.of( new Enum("TestEnum", ImmutableList.of( "TestEnumValue1", "TestEnumValue2")), new Enum("TestEnum2", ImmutableList.of( "TestEnumValue3", "TestEnumValue4"))); final ImmutableList<Struct> allStructs = ImmutableList.of( new Struct("testStruct1", ImmutableList.of( new StructMember(new PrimitiveType("int", false), "structMember1"), new StructMember(new PrimitiveType("ds3_str", true), "structMember2"))), new Struct("testStruct2", "marshallStruct2", ImmutableList.of( new StructMember(new PrimitiveType("int", false), "structMember3")), false, true, false, false)); final Header testHeader = HeaderConverter.toHeader(allEnums, allStructs, allRequests); assertEquals(testHeader.getEnums(), allEnums); assertEquals(testHeader.getRequests(), allRequests); assertEquals(testHeader.getStructs(), allStructs); }
Source:
<code>private void setupUI() { setContentView(R.layout.screen_form_entry); ImageButton nextButton = (ImageButton)this.findViewById(R.id.nav_btn_next); ImageButton prevButton = (ImageButton)this.findViewById(R.id.nav_btn_prev); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!NAV_STATE_DONE.equals(v.getTag())) { GoogleAnalyticsUtils.reportFormNavForward( GoogleAnalyticsFields.LABEL_ARROW, GoogleAnalyticsFields.VALUE_FORM_NOT_DONE); FormEntryActivity.this.showNextView(); } else { GoogleAnalyticsUtils.reportFormNavForward( GoogleAnalyticsFields.LABEL_ARROW, GoogleAnalyticsFields.VALUE_FORM_DONE); triggerUserFormComplete(); } } }); prevButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!NAV_STATE_QUIT.equals(v.getTag())) { GoogleAnalyticsUtils.reportFormNavBackward(GoogleAnalyticsFields.LABEL_ARROW); FormEntryActivity.this.showPreviousView(true); } else { <START> FormEntryActivity.this.triggerUserQuitInput(); <END> } } }); mViewPane = (ViewGroup)findViewById(R.id.form_entry_pane); requestMajorLayoutUpdates(); if (mCurrentView != null) { mCurrentView.teardownView(); } isAnimatingSwipe = false; isDialogShowing = false; mCurrentView = null; mInAnimation = null; mOutAnimation = null; mGestureDetector = new GestureDetector(this); }</code><technical_language>love user's this v. 'back' v. " < Form Name Here" exit forms, actually, record this too</technical_language>

Target:
private void setupUI() { setContentView(R.layout.screen_form_entry); ImageButton nextButton = (ImageButton)this.findViewById(R.id.nav_btn_next); ImageButton prevButton = (ImageButton)this.findViewById(R.id.nav_btn_prev); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!NAV_STATE_DONE.equals(v.getTag())) { GoogleAnalyticsUtils.reportFormNavForward( GoogleAnalyticsFields.LABEL_ARROW, GoogleAnalyticsFields.VALUE_FORM_NOT_DONE); FormEntryActivity.this.showNextView(); } else { GoogleAnalyticsUtils.reportFormNavForward( GoogleAnalyticsFields.LABEL_ARROW, GoogleAnalyticsFields.VALUE_FORM_DONE); triggerUserFormComplete(); } } }); prevButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!NAV_STATE_QUIT.equals(v.getTag())) { GoogleAnalyticsUtils.reportFormNavBackward(GoogleAnalyticsFields.LABEL_ARROW); FormEntryActivity.this.showPreviousView(true); } else { GoogleAnalyticsUtils.reportFormQuitAttempt(GoogleAnalyticsFields.LABEL_PROGRESS_BAR_ARROW); FormEntryActivity.this.triggerUserQuitInput(); } } }); mViewPane = (ViewGroup)findViewById(R.id.form_entry_pane); requestMajorLayoutUpdates(); if (mCurrentView != null) { mCurrentView.teardownView(); } isAnimatingSwipe = false; isDialogShowing = false; mCurrentView = null; mInAnimation = null; mOutAnimation = null; mGestureDetector = new GestureDetector(this); }