auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) { if (shouldAttemptCookieRequest.get()) { HttpURLConnection connection = context.connection.getConnection(); try { boolean renewCookie = false; int statusCode = connection.getResponseCode(); if (statusCode == HttpURLConnection.HTTP_FORBIDDEN || statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) { InputStream errorStream = connection.getErrorStream(); String errorString = null; if (errorStream != null) { try { errorString = IOUtils.toString(errorStream, "UTF-8"); } finally { IOUtils.closeQuietly(errorStream); } } logger.log(Level.FINE, String.format(Locale.ENGLISH, "Intercepted " + "response %d %s", statusCode, errorString)); switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: if (errorString != null && errorString.matches("(?siu)" + ".*\\\"error\\\"\\s*:\\s*\\\"credentials_expired\\\".*")) { renewCookie = true; } else { HttpConnectionInterceptorException toThrow = new HttpConnectionInterceptorException(errorString); toThrow.deserialize = errorString != null; throw toThrow; } break; case HttpURLConnection.HTTP_UNAUTHORIZED: renewCookie = true; break; default: break; } if (renewCookie) { logger.finest("Cookie was invalid. Will attempt to get new cookie."); boolean success = requestCookie(context); if (success) { context.replayRequest = true; } else { context.replayRequest = false; shouldAttemptCookieRequest.set(false); } } } else { storeCookiesFromResponse(connection); } } catch (IOException e) { logger.log(Level.SEVERE, "Error reading response code or body from request", e); } } return context; }

Target:
public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) { try { if (shouldAttemptCookieRequest.get()) { HttpURLConnection connection = context.connection.getConnection(); int statusCode = connection.getResponseCode(); if (statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) { boolean success = requestCookie(context); if (success) { context.replayRequest = true; } else { context.replayRequest = false; shouldAttemptCookieRequest.set(false); } } else { storeCookiesFromResponse(connection); } } } catch (IOException e) { logger.log(Level.SEVERE, "Error reading response code or body from request", e); } return context; }
Source:
public Response add(SampleResponse sampleResponse) { Sample sample = new Sample(); sample.setName(sampleResponse.getName()); Key<Sample> key = dao.add(sample); MensagemResponse msg = new MensagemResponse(); msg.setMsg(ResponseMessageEnum.OK.descricao()); return msg; }

Target:
public Response add(SampleResponse sampleResponse) { Sample sample = new Sample(); sample.setName(sampleResponse.getName()); Key<Sample> key = dao.add(sample); MessageResponse msg = new MessageResponse(); msg.setMsg(ResponseMessageEnum.OK.description()); return msg; }
Source:
public Set<SourceProcessingDetails> getProcessingDetails() { if (sourceProcessingDetails == null) { sourceProcessingDetails = new HashSet<>(); } return sourceProcessingDetails; }

Target:
public Set<SourceProcessingDetails> getProcessingDetails() { return sourceProcessingDetails; }
Source:
public ArrayList<RemoteXBeeDevice> getDevices(String id) { if (id == null) throw new NullPointerException("Device identifier cannot be null."); if (id.length() == 0) throw new IllegalArgumentException("Device identifier cannot be an empty string."); ArrayList<RemoteXBeeDevice> devices = new ArrayList<RemoteXBeeDevice>(); for (RemoteXBeeDevice remote : remotesBy64BitAddr.values()) { if (remote.getNodeID().equals(id)) devices.add(remote); } for (RemoteXBeeDevice remote : remotesBy16BitAddr.values()) { if (remote.getNodeID().equals(id)) devices.add(remote); } return devices; }

Target:
public List<RemoteXBeeDevice> getDevices(String id) { if (id == null) throw new NullPointerException("Device identifier cannot be null."); if (id.length() == 0) throw new IllegalArgumentException("Device identifier cannot be an empty string."); List<RemoteXBeeDevice> devices = new ArrayList<RemoteXBeeDevice>(); for (RemoteXBeeDevice remote : remotesBy64BitAddr.values()) { if (remote.getNodeID().equals(id)) devices.add(remote); } for (RemoteXBeeDevice remote : remotesBy16BitAddr.values()) { if (remote.getNodeID().equals(id)) devices.add(remote); } return devices; }
Source:
void writeElement(ObjectDataOutput out, Entry<Data, Object> entry) throws IOException { out.writeData((Data)entry.getKey()); Object value = entry.getValue(); if (value instanceof Data) { out.writeData((Data)value); } else { out.writeObject(value); } }

Target:
void writeElement(ObjectDataOutput out, Entry<Data, Object> entry) throws IOException { out.writeData(entry.getKey()); IOUtil.writeObject(out, entry.getValue()); }
Source:
private void configureCompilerLog(CompilerConfiguration compilerConfiguration) throws MojoExecutionException { if (log == null) { return; } if (compilerConfiguration.getCustomCompilerArgumentsAsMap().containsKey("-log")) { throw new MojoExecutionException("Compiler logging is configured by the 'log' compiler" + " plugin parameter and the custom compiler argument '-log'. Only either of them is allowed."); } logDirectory.mkdirs(); String logFileName = null; if (".".equals(outputJar.getName())) { logFileName = "@dot"; } else { logFileName = outputJar.getName().replaceAll("/", "_"); } String logPath = logDirectory.getAbsolutePath(); if (!logPath.endsWith(File.separator)) { logPath = logPath + File.separator; } String fileExtension = log; if ("plain".equals(log)) { fileExtension = "log"; } logPath = logPath + logFileName + "." + fileExtension; compilerConfiguration.addCompilerCustomArgument("-log", logPath); }

Target:
private void configureCompilerLog(CompilerConfiguration compilerConfiguration) throws MojoFailureException { if (log == null) { return; } if (compilerConfiguration.getCustomCompilerArgumentsAsMap().containsKey("-log")) { throw new MojoFailureException("Compiler logging is configured by the 'log' compiler" + " plugin parameter and the custom compiler argument '-log'. Only either of them is allowed."); } logDirectory.mkdirs(); String logFileName = null; if (".".equals(outputJar.getName())) { logFileName = "@dot"; } else { logFileName = outputJar.getName().replaceAll("/", "_"); } String logPath = logDirectory.getAbsolutePath(); if (!logPath.endsWith(File.separator)) { logPath = logPath + File.separator; } String fileExtension = log; if ("plain".equals(log)) { fileExtension = "log"; } logPath = logPath + logFileName + "." + fileExtension; compilerConfiguration.addCompilerCustomArgument("-log", logPath); }
Source:
public void paintContent(GC gc) { if (m_statusMessage == null) return; gc.setForeground(IMulticoreVisualizerConstants.COLOR_CPU_FG); gc.setBackground(IMulticoreVisualizerConstants.COLOR_CPU_BG); gc.setForeground(IMulticoreVisualizerConstants.COLOR_LOAD_TEXT); int tx = m_bounds.x; int ty = m_bounds.y + 15; GUIUtils.drawTextAligned(gc, m_statusMessage, tx, ty, true, false); }

Target:
public void paintContent(GC gc) { if (m_statusMessage == null) return; gc.setForeground(IMulticoreVisualizerConstants.COLOR_STATUS_BAR_TEXT); int tx = m_bounds.x; int ty = m_bounds.y + 15; GUIUtils.drawTextAligned(gc, m_statusMessage, tx, ty, true, false); }
Source:
public final int scan(final String table, final String startkey, final int recordcount, final Set<String> fields, final Vector<HashMap<String, ByteIterator>> result) { try { final MongoCollection collection = database.getCollection(table); final Find.Builder find = Find.builder().query(where("_id").greaterThanOrEqualTo(startkey)) .limit(recordcount).batchSize(recordcount).sort(Sort.asc("_id")) .readPreference(readPreference); if (fields != null) { final DocumentBuilder fieldsDoc = BuilderFactory.start(); for (final String field : fields) { fieldsDoc.add(field, INCLUDE); } find.projection(fieldsDoc); } result.ensureCapacity(recordcount); final MongoIterator<Document> cursor = collection.find(find); if (!cursor.hasNext()) { System.err.println("Nothing found in scan for key " + startkey); return StatusCode.ERROR; } while (cursor.hasNext()) { final Document doc = cursor.next(); final HashMap<String, ByteIterator> docAsMap = new HashMap<String, ByteIterator>(); fillMap(docAsMap, doc); result.add(docAsMap); } return StatusCode.OK; } catch (final Exception e) { System.err.println(e.toString()); return StatusCode.ERROR; } }

Target:
public final Status scan(final String table, final String startkey, final int recordcount, final Set<String> fields, final Vector<HashMap<String, ByteIterator>> result) { try { final MongoCollection collection = database.getCollection(table); final Find.Builder find = Find.builder().query(where("_id").greaterThanOrEqualTo(startkey)) .limit(recordcount).batchSize(recordcount).sort(Sort.asc("_id")) .readPreference(readPreference); if (fields != null) { final DocumentBuilder fieldsDoc = BuilderFactory.start(); for (final String field : fields) { fieldsDoc.add(field, INCLUDE); } find.projection(fieldsDoc); } result.ensureCapacity(recordcount); final MongoIterator<Document> cursor = collection.find(find); if (!cursor.hasNext()) { System.err.println("Nothing found in scan for key " + startkey); return Status.NOT_FOUND; } while (cursor.hasNext()) { final Document doc = cursor.next(); final HashMap<String, ByteIterator> docAsMap = new HashMap<String, ByteIterator>(); fillMap(docAsMap, doc); result.add(docAsMap); } return Status.OK; } catch (final Exception e) { System.err.println(e.toString()); return Status.ERROR; } }
Source:
private ZipFileData readCentralDirectory() { try { long eocdLocation = findEndOfCentralDirectoryRecord(); ZipFileData fileData = new ZipFileData(UTF_8); EndOfCentralDirectoryRecord.read(fileData, dataInputSource, eocdLocation); if (fileData.isMaybeZip64()) { try { Zip64EndOfCentralDirectoryLocator.read(fileData, dataInputSource, eocdLocation - Zip64EndOfCentralDirectoryLocator.FIXED_DATA_SIZE); Zip64EndOfCentralDirectory.read(fileData, dataInputSource, fileData.getZip64EndOfCentralDirectoryOffset()); } catch (ZipException e) { } } if (fileData.isZip64()) { readCentralDirectoryFileHeaders(fileData, dataInputSource, fileData.getCentralDirectoryOffset(), fileData.getCharset(), fileData.getExpectedEntries()); } else { long centralDirectoryOffset = eocdLocation - fileData.getCentralDirectorySize(); if ((int) centralDirectoryOffset == (int) fileData.getCentralDirectoryOffset()) { readCentralDirectoryFileHeaders(fileData, dataInputSource, centralDirectoryOffset, fileData.getCharset()); } else { readCentralDirectoryFileHeaders(fileData, dataInputSource, fileData.getCentralDirectoryOffset(), fileData.getCharset(), fileData.getExpectedEntries()); } } return fileData; } catch (IOException e) { throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, e); } }

Target:
private ZipFileData readCentralDirectory() { try { long centralDirectoryEndOffset = getCentralDirectoryEndOffset(); ZipFileData fileData = new ZipFileData(UTF_8); EndOfCentralDirectoryRecord.read(fileData, dataInputSource, centralDirectoryEndOffset); if (fileData.isMaybeZip64()) { try { Zip64EndOfCentralDirectoryLocator.read(fileData, dataInputSource, centralDirectoryEndOffset - Zip64EndOfCentralDirectoryLocator.FIXED_DATA_SIZE); Zip64EndOfCentralDirectory.read(fileData, dataInputSource, fileData.getZip64EndOfCentralDirectoryOffset()); } catch (ZipException e) { } } if (fileData.isZip64()) { readCentralDirectoryFileHeaders(fileData, dataInputSource, fileData.getCentralDirectoryOffset(), fileData.getCharset(), fileData.getExpectedEntries()); } else { long centralDirectoryOffset = centralDirectoryEndOffset - fileData.getCentralDirectorySize(); if ((int) centralDirectoryOffset == (int) fileData.getCentralDirectoryOffset()) { readCentralDirectoryFileHeaders(fileData, dataInputSource, centralDirectoryOffset, fileData.getCharset()); } else { readCentralDirectoryFileHeaders(fileData, dataInputSource, fileData.getCentralDirectoryOffset(), fileData.getCharset(), fileData.getExpectedEntries()); } } return fileData; } catch (IOException e) { throw new PrestoException(DRUID_SEGMENT_LOAD_ERROR, e); } }
Source:
@Test public void defaultTimeOutTest() { assertThat(format(MESSAGE, DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT), abs(getExpectedMillis(DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT) - getBenchmark(() -> stubElements.size())), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF)); timeOutDuration.setTime(15500000, MICROSECONDS); assertThat(format(MESSAGE, 15500000, MICROSECONDS), abs(getExpectedMillis(15500000, MICROSECONDS) - getBenchmark(() -> stubElements.size())), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF)); timeOutDuration.setTime(3, SECONDS); assertThat(format(MESSAGE, 3, SECONDS), abs(getExpectedMillis(3, SECONDS) - getBenchmark(() -> stubElements.size())), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF)); }

Target:
@Test public void defaultTimeOutTest() { assertThat(format(MESSAGE, DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT), getPerformanceDiff(getExpectedMillis(DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT), () -> stubElements.size()), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF_MS)); timeOutDuration.setTime(15500000, MICROSECONDS); assertThat(format(MESSAGE, 15500000, MICROSECONDS), getPerformanceDiff(getExpectedMillis(15500000, MICROSECONDS), () -> stubElements.size()), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF_MS)); timeOutDuration.setTime(3, SECONDS); assertThat(format(MESSAGE, 3, SECONDS), getPerformanceDiff(getExpectedMillis(3, SECONDS), () -> stubElements.size()), lessThanOrEqualTo(ACCEPTABLE_TIME_DIFF_MS)); }
Source:
boolean isVariableHeight(StyleRange style) { if (isWordWrap()) { return style.isVariableHeight(); } return style.font != null || style.rise != 0 || (style.metrics != null && (style.metrics.ascent > 0 || style.metrics.descent > 0)); }

Target:
boolean isVariableHeight(StyleRange style) { return style.isVariableHeight(isWordWrap()); }
Source:
public void log(Event event) { if (this.managementCenterConfig.isEnabled()) { events.add(event); } }

Target:
public void log(Event event) { if (this.managementCenterConfig.isEnabled() && isRunning()) { events.add(event); } }
Source:
public void addListener( Runnable listener, Executor executor ) { f.andThen( new ExecutionCallback<T>() { @Override public void onResponse( T response ) { listener.run(); } @Override public void onFailure( Throwable t ) { logger.error( "Unable to retrieve Ace.", t ); } } ); }

Target:
public void addListener( Runnable listener, Executor executor ) { f.andThen( new ExecutionCallback<T>() { @Override public void onResponse( T response ) { listener.run(); } @Override public void onFailure( Throwable t ) { logger.error( "Unable to retrieve result.", t ); } } ); }
Source:
private void onStateEvent(NodeStateEvent event) { assert adminExecutor.inEventLoop(); this.lastStateEvents.put(event.node, event); if ((event.newState == null || event.newState == NodeState.FORCED_DOWN) && channel != null && !channel.closeFuture().isDone() && event.node.getConnectAddress().equals(channel.remoteAddress())) { LOG.debug( "[{}] Control node was removed or forced down, reconnecting", logPrefix, event.node); reconnectNow(); } }

Target:
private void onStateEvent(NodeStateEvent event) { assert adminExecutor.inEventLoop(); this.lastStateEvents.put(event.node, event); if ((event.newState == null || event.newState == NodeState.FORCED_DOWN) && channel != null && !channel.closeFuture().isDone() && event.node.getConnectAddress().equals(channel.remoteAddress())) { LOG.debug( "[{}] Control node was removed or forced down, reconnecting to a different node", logPrefix, event.node); reconnectNow(); } }
Source:
public static void output(@AggregationState PrecisionRecallState state, BlockBuilder out) { Iterator<BucketResult> resultsIterator = getResultsIterator(state); BlockBuilder entryBuilder = out.beginBlockEntry(); while (resultsIterator.hasNext()) { final BucketResult result = resultsIterator.next(); DoubleType.DOUBLE.writeDouble( entryBuilder, result.truePositive / result.positive); } out.closeEntry(); }

Target:
public static void output(@AggregationState PrecisionRecallState state, BlockBuilder out) { Iterator<BucketResult> resultsIterator = getResultsIterator(state); BlockBuilder entryBuilder = out.beginBlockEntry(); while (resultsIterator.hasNext()) { BucketResult result = resultsIterator.next(); DoubleType.DOUBLE.writeDouble( entryBuilder, result.getTruePositive() / result.getPositive()); } out.closeEntry(); }
Source:
public void initStore(Store<?, ?> resource) { Map.Entry<CachingTier.Provider, AuthoritativeTier.Provider> entry = providersMap.get(resource); if (entry == null) { throw new IllegalArgumentException("Given store is not managed by this provider : " + resource); } CacheStore cacheStore = (CacheStore) resource; entry.getKey().initCachingTier(cacheStore.cachingTier()); entry.getValue().initAuthoritativeTier(cacheStore.authoritativeTier); }

Target:
public void initStore(Store<?, ?> resource) { Map.Entry<CachingTier.Provider, AuthoritativeTier.Provider> entry = providersMap.get(resource); if (entry == null) { throw new IllegalArgumentException("Given store is not managed by this provider : " + resource); } CacheStore cacheStore = (CacheStore) resource; entry.getKey().initCachingTier(cacheStore.realCachingTier); entry.getValue().initAuthoritativeTier(cacheStore.authoritativeTier); }
Source:
@Override public void request(int rowsCnt) { assert !F.isEmpty(sources()) && sources().size() == 1; assert rowsCnt > 0; try { checkState(); requested += rowsCnt; if (waiting == -1) context().execute(this::doPush); else if (waiting == 0) source().request(waiting = IN_BUFFER_SIZE); } catch (Exception e) { onError(e); } }

Target:
@Override public void request(int rowsCnt) { assert !F.isEmpty(sources()) && sources().size() == 1; assert rowsCnt > 0; try { checkState(); requested += rowsCnt; if (waiting == -1 && !inLoop) context().execute(this::doPush); else if (waiting == 0) source().request(waiting = IN_BUFFER_SIZE); } catch (Exception e) { onError(e); } }
Source:
public SaProposal getVerifiedNegotiatedProposal(IkeSaPayload reqSaPayload) throws NoValidProposalChosenException { if (!isSaResponse) { throw new UnsupportedOperationException( "Cannot get negotiated SA proposal from a request message."); } Proposal respProposal = proposalList.get(0); if (respProposal.hasUnrecognizedTransform) { throw new NoValidProposalChosenException( "Negotiated proposal has unrecognized Transform."); } int negotiatedProposalNum = proposalList.get(0).number; List<Proposal> reqProposalList = reqSaPayload.proposalList; if (negotiatedProposalNum < 1 || negotiatedProposalNum > reqProposalList.size()) { throw new NoValidProposalChosenException( "Negotiated proposal has invalid proposal number."); } Proposal reqProposal = reqProposalList.get(negotiatedProposalNum - 1); if (!respProposal.isNegotiatedFrom(reqProposal)) { throw new NoValidProposalChosenException("Invalid negotaited proposal."); } return respProposal.saProposal; }

Target:
public SaProposal getVerifiedNegotiatedProposal(IkeSaPayload reqSaPayload) throws NoValidProposalChosenException { if (!isSaResponse) { throw new UnsupportedOperationException( "Cannot get negotiated SA proposal from a request message."); } Proposal respProposal = proposalList.get(0); if (respProposal.hasUnrecognizedTransform) { throw new NoValidProposalChosenException( "Negotiated proposal has unrecognized Transform."); } int negotiatedProposalNum = proposalList.get(0).number; List<Proposal> reqProposalList = reqSaPayload.proposalList; if (negotiatedProposalNum < 1 || negotiatedProposalNum > reqProposalList.size()) { throw new NoValidProposalChosenException( "Negotiated proposal has invalid proposal number."); } Proposal reqProposal = reqProposalList.get(negotiatedProposalNum - 1); if (!respProposal.isNegotiatedFrom(reqProposal)) { throw new NoValidProposalChosenException("Invalid negotiated proposal."); } return respProposal.saProposal; }
Source:
public static Command createCommand(Message message, CommandContext context) { checkNotNull(message); checkNotNull(context); final Any packed = AnyPacker.pack(message); final Command.Builder request = Command.newBuilder() .setMessage(packed) .setContext(context); return request.build(); }

Target:
public static Command createCommand(Message message, CommandContext context) { checkNotNull(message); checkNotNull(context); final Any packed = AnyPacker.pack(message); final Command.Builder result = Command.newBuilder() .setMessage(packed) .setContext(context); return result.build(); }
Source:
private void assertRegionVersionVectorsConsistency(int bucketId, BucketDump bucketDump1, BucketDump bucketDump2) { RegionVersionVector rvv1 = bucketDump1.getRvv(); RegionVersionVector rvv2 = bucketDump2.getRvv(); if (rvv1 == null) { assertThat(rvv2) .as("Bucket " + bucketId + " has an RVV on member " + bucketDump2.getMember() + ", but does not on member " + bucketDump1.getMember()) .isNull(); } if (rvv2 == null) { assertThat(rvv1) .as("Bucket " + bucketId + " has an RVV on member " + bucketDump1.getMember() + ", but does not on member " + bucketDump2.getMember()) .isNull(); } assertThat(rvv1).isNotNull(); assertThat(rvv2).isNotNull(); Map<VersionSource, RegionVersionHolder> rvv2Members = new HashMap<VersionSource, RegionVersionHolder>(rvv1.getMemberToVersion()); Map<VersionSource, RegionVersionHolder> rvv1Members = new HashMap<VersionSource, RegionVersionHolder>(rvv1.getMemberToVersion()); for (Map.Entry<VersionSource, RegionVersionHolder> entry : rvv1Members.entrySet()) { VersionSource memberId = entry.getKey(); RegionVersionHolder versionHolder1 = entry.getValue(); RegionVersionHolder versionHolder2 = rvv2Members.remove(memberId); assertThat(versionHolder1) .as("RegionVersionVector for bucket " + bucketId + " on member " + bucketDump1.getMember() + " is not consistent with member " + bucketDump2.getMember()) .isEqualTo(versionHolder2); } }

Target:
private void assertRegionVersionVectorsConsistency(int bucketId, BucketDump bucketDump1, BucketDump bucketDump2) { RegionVersionVector<?> rvv1 = bucketDump1.getRvv(); RegionVersionVector<?> rvv2 = bucketDump2.getRvv(); if (rvv1 == null) { assertThat(rvv2) .as("Bucket " + bucketId + " has an RVV on member " + bucketDump2.getMember() + ", but does not on member " + bucketDump1.getMember()) .isNull(); } if (rvv2 == null) { assertThat(rvv1) .as("Bucket " + bucketId + " has an RVV on member " + bucketDump1.getMember() + ", but does not on member " + bucketDump2.getMember()) .isNull(); } assertThat(rvv1).isNotNull(); assertThat(rvv2).isNotNull(); Map<VersionSource<?>, RegionVersionHolder<?>> rvv2Members = new HashMap<>(rvv1.getMemberToVersion()); Map<VersionSource<?>, RegionVersionHolder<?>> rvv1Members = new HashMap<>(rvv1.getMemberToVersion()); for (Map.Entry<VersionSource<?>, RegionVersionHolder<?>> entry : rvv1Members.entrySet()) { VersionSource<?> memberId = entry.getKey(); RegionVersionHolder<?> versionHolder1 = entry.getValue(); RegionVersionHolder<?> versionHolder2 = rvv2Members.remove(memberId); assertThat(versionHolder1) .as("RegionVersionVector for bucket " + bucketId + " on member " + bucketDump1.getMember() + " is not consistent with member " + bucketDump2.getMember()) .isEqualTo(versionHolder2); } }
Source:
public void writeBloomFilter(BloomFilter bloomFilter) { currentBloomFilters.add(bloomFilter); }

Target:
void writeBloomFilter(BloomFilter bloomFilter) { currentBloomFilters.add(bloomFilter); }
Source:
public boolean isCompileTimeConstant(ASTPrimaryExpression expressions) { List<ASTPrimarySuffix> suffix = expressions.findDescendantsOfType(ASTPrimarySuffix.class); if (!suffix.isEmpty()) { return false; } List<ASTName> nameNodes = expressions.findDescendantsOfType(ASTName.class); List<ASTLiteral> literalNodes = expressions.findDescendantsOfType(ASTLiteral.class); if (nameNodes.size() + literalNodes.size() < 2) { for (ASTName node: nameNodes) { if (cache.containsKey(node.getImage())) { return cache.get(node.getImage()); } } return true; } List<ASTPrimaryExpression> subExpressions = expressions.findDescendantsOfType(ASTPrimaryExpression.class); for (ASTPrimaryExpression exp: subExpressions) { if (!isCompileTimeConstant(exp)) { return false; } } return true; }

Target:
public boolean isCompileTimeConstant(ASTPrimaryExpression expressions) { List<ASTPrimarySuffix> suffix = expressions.findDescendantsOfType(ASTPrimarySuffix.class); if (!suffix.isEmpty()) { return false; } List<ASTName> nameNodes = expressions.findDescendantsOfType(ASTName.class); List<ASTLiteral> literalNodes = expressions.findDescendantsOfType(ASTLiteral.class); if (nameNodes.size() + literalNodes.size() < 2) { for (ASTName node: nameNodes) { if (!cache.contains(node.getImage())) { return false; } } return true; } List<ASTPrimaryExpression> subExpressions = expressions.findDescendantsOfType(ASTPrimaryExpression.class); for (ASTPrimaryExpression exp: subExpressions) { if (!isCompileTimeConstant(exp)) { return false; } } return true; }
Source:
public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof ImmutablePair)) { return false; } ImmutablePair<?, ?> other = (ImmutablePair<?, ?>) o; boolean fst; if (first == null) { if (other.first == null) { fst = true; } else { return false; } } else if (other.first == null) { return false; } else { fst = first.equals(other.first); } boolean snd; if (second == null) { if (other.second == null) { snd = true; } else { return false; } } else if (other.second == null) { return false; } else { snd = second.equals(other.second); } return fst && snd; }

Target:
public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof ImmutablePair)) { return false; } ImmutablePair<?, ?> other = (ImmutablePair<?, ?>) o; return equals(first, other.first) && equals(second, other.second); }
Source:
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SupportedApiVersionCommand that = (SupportedApiVersionCommand) o; if (_apiVersion != null ? !_apiVersion.equals(that._apiVersion) : that._apiVersion != null) return false; return true; }

Target:
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof SupportedApiVersionCommand)) return false; if (!super.equals(o)) return false; SupportedApiVersionCommand that = (SupportedApiVersionCommand) o; if (_apiVersion != null ? !_apiVersion.equals(that._apiVersion) : that._apiVersion != null) return false; return true; }
Source:
public final void run() { logger.fine("GridTimer[" + name + "].run() called"); if (repetitions > 0) { repetitions--; } else if (repetitions == 0) { cycleRate(); } logger.fine("GridTimer[" + name + "] Executing! Current Rate: " + rateCycle[currentRate] + ":" + getRefreshRate() + " Reps: " + repetitions); execute(); Configurator conf = (Configurator) TypeResolver.getInstance() .resolve(Configurator.class); conf.getRefreshRate(); int interval = conf.getPollingTimerInterval(); if (interval != normalInterval) { setRefreshRate(interval); } }

Target:
public final void run() { logger.fine("GridTimer[" + name + "].run() called"); if (repetitions > 0) { repetitions--; } else if (repetitions == 0) { cycleRate(); } logger.fine("GridTimer[" + name + "] Executing! Current Rate: " + rateCycle[currentRate] + ":" + getRefreshRate() + " Reps: " + repetitions); execute(); syncRefreshRate(); }
Source:
public String runTask(StressBenchConfig config, ArrayList<String> args, RunTaskContext runTaskContext) throws Exception { List<String> command = new ArrayList<>(3 + config.getArgs().size()); command.add(ServerConfiguration.get(PropertyKey.HOME) + "/bin/alluxio"); command.add("runClass"); command.add(config.getClassName()); command.addAll(config.getArgs()); command.add(BaseParameters.DISTRIBUTED_FLAG); command.add(BaseParameters.IN_PROCESS_FLAG); if (config.getArgs().stream().noneMatch((s) -> s.equals("--start-ms"))) { command.add("--start-ms"); command.add(Long.toString((System.currentTimeMillis() + 5000))); } command.addAll(args); LOG.info("running command: " + String.join(" ", command)); String output = ShellUtils.execCommand(command.toArray(new String[0])); return output; }

Target:
public String runTask(StressBenchConfig config, ArrayList<String> args, RunTaskContext runTaskContext) throws Exception { List<String> command = new ArrayList<>(3 + config.getArgs().size()); command.add(ServerConfiguration.get(PropertyKey.HOME) + "/bin/alluxio"); command.add("runClass"); command.add(config.getClassName()); command.addAll(config.getArgs()); command.add(BaseParameters.DISTRIBUTED_FLAG); command.add(BaseParameters.IN_PROCESS_FLAG); if (config.getArgs().stream().noneMatch((s) -> s.equals(BaseParameters.START_MS_FLAG))) { command.add(BaseParameters.START_MS_FLAG); command.add(Long.toString((System.currentTimeMillis() + 5000))); } command.addAll(args); LOG.info("running command: " + String.join(" ", command)); String output = ShellUtils.execCommand(command.toArray(new String[0])); return output; }
Source:
protected String getUrlForPatchSetOrBase(final Patch.Key key, final PatchSet.Id id) throws GerritException { String leftKey; if (id == null) { leftKey = encode(key.toString() + "^1"); } else { leftKey = getUrlForPatchSet(key, id); } return leftKey; }

Target:
protected String getUrlForPatchSetOrBase(final Patch.Key key, final PatchSet.Id id) throws GerritException { if (id == null) { return getUrlForBase(key); } else { return getUrlForPatchSet(key, id); } }
Source:
private int readAllNulls(int[] positions, int positionCount) throws IOException { presentStream.skip(positions[positionCount - 1]); if (nullsAllowed) { if (nullsFilter != null) { for (int i = 0; i < positionCount; i++) { if (nullsFilter.testNull()) { outputPositionCount++; } else { outputPositionCount -= nullsFilter.getPrecedingPositionsToFail(); i += nullsFilter.getSucceedingPositionsToFail(); } } } else { outputPositionCount = positionCount; outputPositions = positions; } } else { outputPositionCount = 0; } if (listFilter != null) { listFilter.populateElementFilters(0, null, null, 0); } allNulls = true; return positions[positionCount - 1] + 1; }

Target:
private int readAllNulls(int[] positions, int positionCount) throws IOException { presentStream.skip(positions[positionCount - 1]); if (nullsAllowed) { if (nullsFilter != null) { outputPositionCount = 0; for (int i = 0; i < positionCount; i++) { if (nullsFilter.testNull()) { outputPositions[outputPositionCount] = positions[i]; outputPositionCount++; } else { outputPositionCount -= nullsFilter.getPrecedingPositionsToFail(); i += nullsFilter.getSucceedingPositionsToFail(); } } } else { outputPositionCount = positionCount; outputPositions = positions; outputPositionsReadOnly = true; } } else { outputPositionCount = 0; } if (listFilter != null) { listFilter.populateElementFilters(0, null, null, 0); } allNulls = true; return positions[positionCount - 1] + 1; }
Source:
public void writeTo(IndentingWriter writer, MavenBuild build) { MavenBuildSettings settings = build.getSettings(); MavenDistributionManagement distributionManagement = build.getDistributionManagement(); writeProject(writer, () -> { writeParent(writer, build); writeProjectCoordinates(writer, settings); writePackaging(writer, settings); writeProjectName(writer, settings); writeProperties(writer, build.properties()); writeDependencies(writer, build); writeDependencyManagement(writer, build); writeBuild(writer, build); writeRepositories(writer, build); writeDistributionManagement(writer, distributionManagement); }); }

Target:
public void writeTo(IndentingWriter writer, MavenBuild build) { MavenBuildSettings settings = build.getSettings(); writeProject(writer, () -> { writeParent(writer, build); writeProjectCoordinates(writer, settings); writePackaging(writer, settings); writeProjectName(writer, settings); writeProperties(writer, build.properties()); writeDependencies(writer, build); writeDependencyManagement(writer, build); writeBuild(writer, build); writeRepositories(writer, build); writeDistributionManagement(writer, build); }); }
Source:
private void setMessageHeaders(Message msg, Map<Header, Object> headers) throws ProducerException { if (msg != null && headers != null) { for (Map.Entry<Header, Object> header : headers.entrySet()) { Method method; try { method = msg.getClass().getMethod("set" + header.getKey().getJmsMessage() , String.class); method.invoke(msg, header.getValue()); } catch (Exception e) { throw new ProducerException("Failed to set message header", e); } } } }

Target:
private void setMessageHeaders(Message msg, Map<Header, Object> headers) throws ProducerException { if (msg != null && headers != null) { headers.entrySet().stream().filter(entry -> entry.getValue() != null) .forEach(entry -> { if(ActiveMQHeaders.getFunctions().get(entry.getKey()).get((ActiveMQMessage)msg) == null) { ActiveMQHeaders.getFunctions().get(entry.getKey()).set((ActiveMQMessage)msg,entry.getValue()); } }); } }
Source:
public BudgetGoal() { super(); }

Target:
public BudgetGoal() { }
Source:
public void startRemain() { if (outputEmitter != null) { result = scheduler.scheduleAtFixedRate(new Runnable() { public void run() { outputEmitter.emitWatermark(new MistWatermarkEvent(System.currentTimeMillis() - expectedDelay)); } }, period, period, timeUnit); } else { throw new RuntimeException("OutputEmitter should be set in " + SourceImpl.class.getName()); } }

Target:
protected void startRemain() { result = scheduler.scheduleAtFixedRate(new Runnable() { public void run() { outputEmitter.emitWatermark(new MistWatermarkEvent(getCurrentTimestamp() - expectedDelay)); } }, period, period, timeUnit); }
Source:
public void testBeanMetaDataClassNormalizerNoNormalizer() { Set<ConstraintViolation<Bean>> violations = getValidator().validate( new BeanProxy() ); assertNoViolations( violations ); Set<Class<?>> beanMetaDataToInitialize = new HashSet<>(); beanMetaDataToInitialize.add( Bean.class ); ValidatorFactory validatorFactory = Validation.byProvider( PredefinedScopeHibernateValidator.class ) .configure() .initializeBeanMetaData( beanMetaDataToInitialize ) .initializeLocales( Collections.singleton( Locale.getDefault() ) ) .buildValidatorFactory(); violations = validatorFactory.getValidator().validate( new BeanProxy() ); assertNoViolations( violations ); }

Target:
public void testBeanMetaDataClassNormalizerNoNormalizer() { Set<ConstraintViolation<Bean>> violations = getValidator().validate( new BeanProxy() ); assertNoViolations( violations ); Set<Class<?>> beanMetaDataToInitialize = new HashSet<>(); beanMetaDataToInitialize.add( Bean.class ); ValidatorFactory validatorFactory = Validation.byProvider( PredefinedScopeHibernateValidator.class ) .configure() .initializeBeanMetaData( beanMetaDataToInitialize ) .locales( Collections.singleton( Locale.getDefault() ) ) .buildValidatorFactory(); violations = validatorFactory.getValidator().validate( new BeanProxy() ); assertNoViolations( violations ); }
Source:
protected boolean canTakeDamage(EntityDamageEvent.DamageCause damageCause) { return gameMode == GameMode.SURVIVAL || gameMode == GameMode.ADVENTURE && super.canTakeDamage(damageCause); }

Target:
protected boolean canTakeDamage(EntityDamageEvent.DamageCause damageCause) { return (gameMode == GameMode.SURVIVAL || gameMode == GameMode.ADVENTURE) && super.canTakeDamage(damageCause); }
Source:
protected Object applyEntryValueToMap(Entry value, Map target) { Object k = value.getKey(); if (acceptsSubkeyStronglyTyped(k)) { } else if (k instanceof ConfigKey<?>) { k = subKey( ((ConfigKey<?>)k).getName() ); } else if (k instanceof String) { k = subKey((String)k); } else { if (k instanceof Supplier) { Object mapAtRoot = target.get(this); if (mapAtRoot==null) { mapAtRoot = new LinkedHashMap(); target.put(this, mapAtRoot); } if (mapAtRoot instanceof Map) { synchronized (mapAtRoot) { return ((Map)mapAtRoot).put(k, value.getValue()); } } } log.warn("Unexpected subkey "+k+" being inserted into "+this+"; ignoring"); k = null; } if (k!=null) return target.put(k, value.getValue()); else return null; }

Target:
protected Object applyEntryValueToMap(Entry value, Map target) { Object k = value.getKey(); if (acceptsSubkeyStronglyTyped(k)) { } else if (k instanceof ConfigKey<?>) { k = subKey( ((ConfigKey<?>)k).getName() ); } else if (k instanceof String) { k = subKey((String)k); } else { if (k instanceof Supplier) { Object mapAtRoot = target.get(this); if (mapAtRoot==null) { mapAtRoot = new LinkedHashMap(); target.put(this, mapAtRoot); } if (mapAtRoot instanceof Map) { if (mapAtRoot instanceof ConcurrentMap) { return ((Map)mapAtRoot).put(k, value.getValue()); } else { synchronized (mapAtRoot) { return ((Map)mapAtRoot).put(k, value.getValue()); } } } } log.warn("Unexpected subkey "+k+" being inserted into "+this+"; ignoring"); k = null; } if (k!=null) return target.put(k, value.getValue()); else return null; }
Source:
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable tvp1 = args[0]; ObjectPointable op; if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) { pointables = new ArrayList<>(); TaggedValuePointable temptvp = ppool.takeOne(TaggedValuePointable.class); try { tvp1.getValue(sp1); int size1 = sp1.getEntryCount(); int size2; for (int i = 0; i < size1; i++) { sp1.getEntry(i, temptvp); if (temptvp.getTag() == ValueTag.OBJECT_TAG) { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); temptvp.getValue(op); op.getKeys(temptvp); temptvp.getValue(sp2); size2 = sp2.getEntryCount(); for (int j = 0; j < size2; j++) { TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY .createPointable(); sp2.getEntry(j, tvp); pointables.add(tvp); } } } removeDuplicates(pointables); abvs.reset(); sb.reset(abvs); for (TaggedValuePointable tvp : pointables) { sb.addItem(tvp); } sb.finish(); result.set(abvs); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { ppool.giveBack(temptvp); } } else if (tvp1.getTag() == ValueTag.OBJECT_TAG) { try { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); tvp1.getValue(op); op.getKeys(result); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } } else { XDMConstants.setEmptySequence(result); } }

Target:
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { TaggedValuePointable tvp1 = args[0]; ObjectPointable op; pointables.clear(); if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) { TaggedValuePointable temptvp = ppool.takeOne(TaggedValuePointable.class); try { tvp1.getValue(sp1); int size1 = sp1.getEntryCount(); int size2; for (int i = 0; i < size1; i++) { sp1.getEntry(i, temptvp); if (temptvp.getTag() == ValueTag.OBJECT_TAG) { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); temptvp.getValue(op); op.getKeys(temptvp); temptvp.getValue(sp2); size2 = sp2.getEntryCount(); for (int j = 0; j < size2; j++) { TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY .createPointable(); sp2.getEntry(j, tvp); pointables.add(tvp); } } } removeDuplicates(pointables); abvs.reset(); sb.reset(abvs); for (TaggedValuePointable tvp : pointables) { sb.addItem(tvp); } sb.finish(); result.set(abvs); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } finally { ppool.giveBack(temptvp); } } else if (tvp1.getTag() == ValueTag.OBJECT_TAG) { try { op = (ObjectPointable) ObjectPointable.FACTORY.createPointable(); tvp1.getValue(op); op.getKeys(result); } catch (IOException e) { throw new SystemException(ErrorCode.SYSE0001, e); } } else { XDMConstants.setEmptySequence(result); } }
Source:
public void onStop() { if (mRequireRestart) { if (mApi != null && mSyncthingService.getCurrentState() != SyncthingService.State.DISABLED) { mApi.restart(); mRequireRestart = false; } } super.onStop(); }

Target:
public void onStop() { if (mRequireRestart) { if (mSyncthingService != null && mApi != null && mSyncthingService.getCurrentState() != SyncthingService.State.DISABLED) { mApi.restart(); mRequireRestart = false; } } super.onStop(); }
Source:
public static Credential authorize() { try { GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( HTTP_TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, SCOPES) .setDataStoreFactory(DATA_STORE_FACTORY) .setAccessType("offline") .build(); Credential credential = new AuthorizationCodeInstalledApp( flow, new LocalServerReceiver()).authorize("ganttuser"); System.out.println( "Credentials saved to " + DATA_STORE_DIR.getAbsolutePath()); return credential; } catch (IOException e) { e.printStackTrace(); return null; } }

Target:
public Credential authorize() throws GeneralSecurityException, IOException { HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, SCOPES) .build(); return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("ganttuser"); }
Source:
public Response add(Event event) { validateParameters(event, "origin", "severity", "eventFloodInSec", "description"); AuditLog entity = map(event); return performCreation(VdcActionType.AddExternalEvent, new AddExternalEventParameters(entity), new QueryIdResolver<Long>(VdcQueryType.GetAuditLogById, GetAuditLogByIdParameters.class)); }

Target:
public Response add(Event event) { validateParameters(event, "origin", "severity", "customId", "description"); return performCreation(VdcActionType.AddExternalEvent, new AddExternalEventParameters(map(event)), new QueryIdResolver<Long>(VdcQueryType.GetAuditLogById, GetAuditLogByIdParameters.class)); }
Source:
public void deleteQuestion(@Load Question question) { if (!environment.supports("deletable.questions")) { result.notFound(); return; } if (!currentUser.isModerator() && !question.hasAuthor(currentUser.getCurrent())) { result.use(http()).sendError(403); return; } I18nMessage errorMessage = messageFactory.build("error", "question.errors.deletion"); if (!question.isDeletable()) { result.use(http()) .body(errorMessage.getMessage()) .setStatusCode(400); return; } questions.delete(question); result.nothing(); }

Target:
public void deleteQuestion(@Load Question question) { if (!environment.supports("deletable.questions")) { result.notFound(); return; } if (!currentUser.isModerator() && !question.hasAuthor(currentUser.getCurrent())) { result.use(http()).sendError(403); return; } I18nMessage errorMessage = messageFactory.build("error", "question.errors.deletion"); if (!question.isDeletable()) { result.use(http()) .body(errorMessage.getMessage()) .setStatusCode(400); return; } result.include("mamuteMessages", asList(messageFactory.build("confirmation", "question.delete.confirmation"))); questions.delete(question); result.redirectTo(ListController.class).home(null); }
Source:
public void render(AbstractScreen screen) { if((justDroppedTicks-- > 0 || isHighlight()) && MojamComponent.localTeam==team) { drawRadius(screen); } super.render(screen); AbstractBitmap image = getSprite(); if (capacity - money < 500) { screen.colorBlit(image, pos.x - image.getWidth() / 2, pos.y - image.getHeight() / 2 - yOffs, 0x77ff7200); } if( team == MojamComponent.localTeam ) { addMoneyBar(screen); } }

Target:
public void render(AbstractScreen screen) { if((justDroppedTicks-- > 0 || isHighlight()) && MojamComponent.localTeam==team) { drawRadius(screen); } super.render(screen); AbstractBitmap image = getSprite(); if (capacity - money < 500) { screen.colorBlit(image, pos.x - image.getWidth() / 2, pos.y - image.getHeight() / 2 - yOffs, 0x77ff7200); } if( team == MojamComponent.localTeam && !(isCarried() && this.carriedBy instanceof Player)) { addMoneyBar(screen); } }
Source:
private Intent getPlayLastPlayedMediaIntent() { Log.d(TAG, "Trying to restore last played media"); Playable media = PlayableUtils.createInstanceFromPreferences(activity); if (media != null) { Intent serviceIntent = new Intent(activity, PlaybackService.class); serviceIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, media); serviceIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED, false); serviceIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY, true); boolean fileExists = media.localFileAvailable(); boolean lastIsStream = PlaybackPreferences.getCurrentEpisodeIsStream(); if (!fileExists && !lastIsStream && media instanceof FeedMedia) { DBTasks.notifyMissingFeedMediaFile(activity, (FeedMedia) media); } serviceIntent.putExtra(PlaybackService.EXTRA_SHOULD_STREAM, lastIsStream || !fileExists); return serviceIntent; } Log.d(TAG, "No last played media found"); return null; }

Target:
@Nullable private Intent getPlayLastPlayedMediaIntent() { Log.d(TAG, "Trying to restore last played media"); Playable media = PlayableUtils.createInstanceFromPreferences(activity); if (media == null) { Log.d(TAG, "No last played media found"); return null; } boolean fileExists = media.localFileAvailable(); boolean lastIsStream = PlaybackPreferences.getCurrentEpisodeIsStream(); if (!fileExists && !lastIsStream && media instanceof FeedMedia) { DBTasks.notifyMissingFeedMediaFile(activity, (FeedMedia) media); } return new PlaybackServiceStarter(activity, media) .startWhenPrepared(false) .shouldStream(lastIsStream || !fileExists) .getIntent(); }
Source:
private void configureHardWrap() { if (shouldHardWrap()) { if (hardWrapSegmentListener == null) { final StyledText textWidget = getTextWidget(); hardWrapSegmentListener = new BidiSegmentListener() { public void lineGetSegments(BidiSegmentEvent e) { int[] segments = calculateWrapOffsets(e.lineText, MAX_LINE_WIDTH); if (segments != null) { char[] segmentsChars = new char[segments.length]; Arrays.fill(segmentsChars, '\n'); e.segments = segments; e.segmentsChars = segmentsChars; } } }; textWidget.addBidiSegmentListener(hardWrapSegmentListener); textWidget.setText(textWidget.getText()); if (brokenBidiPlatformTextWidth != -1) { Layout restrictedWidthLayout = new Layout() { @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = SpellcheckableMessageArea.this .getSize(); Rectangle trim = SpellcheckableMessageArea.this .computeTrim(0, 0, 0, 0); size.x -= trim.width; size.y -= trim.height; if (size.x > brokenBidiPlatformTextWidth) size.x = brokenBidiPlatformTextWidth; return size; } @Override protected void layout(Composite composite, boolean flushCache) { Point size = computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache); textWidget.setBounds(0, 0, size.x, size.y); } }; setLayout(restrictedWidthLayout); } } } else if (hardWrapSegmentListener != null) { StyledText textWidget = getTextWidget(); textWidget.removeBidiSegmentListener(hardWrapSegmentListener); textWidget.setText(textWidget.getText()); hardWrapSegmentListener = null; if (brokenBidiPlatformTextWidth != -1) { setLayout(new FillLayout()); } } }

Target:
private void configureHardWrap() { if (shouldHardWrap()) { if (hardWrapSegmentListener == null) { final StyledText textWidget = getTextWidget(); hardWrapSegmentListener = new BidiSegmentListener() { public void lineGetSegments(BidiSegmentEvent e) { int[] segments = calculateWrapOffsets(e.lineText, MAX_LINE_WIDTH); if (segments != null) { char[] segmentsChars = new char[segments.length]; Arrays.fill(segmentsChars, '\n'); e.segments = segments; e.segmentsChars = segmentsChars; } } }; textWidget.addBidiSegmentListener(hardWrapSegmentListener); textWidget.setText(textWidget.getText()); if (brokenBidiPlatformTextWidth != -1) { Layout restrictedWidthLayout = new Layout() { @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = SpellcheckableMessageArea.this .getSize(); Rectangle trim = SpellcheckableMessageArea.this .computeTrim(0, 0, 0, 0); size.x -= trim.width; size.y -= trim.height; if (size.x > brokenBidiPlatformTextWidth) size.x = brokenBidiPlatformTextWidth; return size; } @Override protected void layout(Composite composite, boolean flushCache) { Point size = computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache); textWidget.setBounds(0, 0, size.x, size.y); } }; setLayout(restrictedWidthLayout); } } } else if (hardWrapSegmentListener != null) { StyledText textWidget = getTextWidget(); textWidget.removeBidiSegmentListener(hardWrapSegmentListener); textWidget.setText(textWidget.getText()); hardWrapSegmentListener = null; if (brokenBidiPlatformTextWidth != -1) setLayout(new FillLayout()); } }