auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public CoapObserveRelation observeAndWait(Request request, CoapHandler handler) { if (request.getOptions().hasObserve()) { Endpoint outEndpoint = getEffectiveEndpoint(request); CoapObserveRelation relation = new CoapObserveRelation(request, outEndpoint); request.addMessageObserver(new ObserveMessageObserverImpl(handler, relation)); CoapResponse response = synchronous(request, outEndpoint); if (response == null || !response.advanced().getOptions().hasObserve()) relation.setCanceled(true); relation.setCurrent(response); return relation; } else { throw new IllegalStateException("please make sure that the request has observe option set."); } }

Target:
public CoapObserveRelation observeAndWait(Request request, CoapHandler handler) { if (request.getOptions().hasObserve()) { Endpoint outEndpoint = getEffectiveEndpoint(request); CoapObserveRelation relation = new CoapObserveRelation(request, outEndpoint); request.addMessageObserver(new ObserveMessageObserverImpl(handler, relation)); CoapResponse response = synchronous(request, outEndpoint); if (response == null || !response.advanced().getOptions().hasObserve()) relation.setCanceled(true); relation.setCurrent(response); return relation; } else { throw new IllegalArgumentException("please make sure that the request has observe option set."); } }
Source:
public final void writeSelf(FileChannel fc) throws IOException { fRwl.readLock().lock(); try { final int blockSize = fConfig.getBlockSize(); ByteBuffer buffer = ByteBuffer.allocate(blockSize); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.clear(); buffer.put(getNodeType().toByte()); buffer.putLong(fNodeStart); buffer.putLong(fNodeEnd); buffer.putInt(fSequenceNumber); buffer.putInt(fParentSequenceNumber); buffer.putInt(fIntervals.size()); buffer.put((byte) 1); writeSpecificHeader(buffer); fIntervals.forEach(i->i.writeInterval(buffer)); while (buffer.position() < blockSize) { buffer.put((byte) 0); } buffer.position(blockSize); buffer.flip(); int res = fc.write(buffer); if (res != blockSize) { throw new IllegalStateException("Wrong size of block written: Actual: " + res + ", Expected: " + blockSize); } } finally { fRwl.readLock().unlock(); } fIsOnDisk = true; }

Target:
public final void writeSelf(FileChannel fc) throws IOException { fRwl.readLock().lock(); try { final int blockSize = fConfig.getBlockSize(); ByteBuffer buffer = ByteBuffer.allocate(blockSize); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.clear(); buffer.put(getNodeType().toByte()); buffer.putLong(fNodeStart); buffer.putLong(fNodeEnd); buffer.putInt(fSequenceNumber); buffer.putInt(fParentSequenceNumber); buffer.putInt(fIntervals.size()); buffer.put((byte) 1); writeSpecificHeader(buffer); fIntervals.forEach(i->i.writeInterval(buffer)); while (buffer.position() < blockSize) { buffer.put((byte) 0); } buffer.flip(); int res = fc.write(buffer); if (res != blockSize) { throw new IllegalStateException("Wrong size of block written: Actual: " + res + ", Expected: " + blockSize); } } finally { fRwl.readLock().unlock(); } fIsOnDisk = true; }
Source:
private static Map<String, FormatValidator> formatValidators(Map<String, FormatValidator> parent, FormatValidator... validators) { Map<String, FormatValidator> validatorMap = parent == null ? new HashMap<>() : new HashMap<>(parent); for(FormatValidator validator : validators) validatorMap.put(validator.formatName(), validator); return unmodifiableMap(validatorMap); }

Target:
private static Map<String, FormatValidator> formatValidators(Map<String, FormatValidator> parent, FormatValidator... validators) { Map<String, FormatValidator> validatorMap = (parent == null) ? new HashMap<>() : new HashMap<>(parent); for(FormatValidator validator : validators) { validatorMap.put(validator.formatName(), validator); } return unmodifiableMap(validatorMap); }
Source:
public void registerClientInformation(final ClientInformation clientInformation) { if (this.clientInformation != null) { sensors.connectionsByClient.decrement(this.clientInformation); } this.clientInformation = clientInformation; sensors.connectionsByClient.increment(clientInformation); }

Target:
public void registerClientInformation(final ClientInformation clientInformation) { if (this.clientInformation != null) { if (this.clientInformation.equals(clientInformation)) return; sensors.connectionsByClient.decrement(this.clientInformation); } this.clientInformation = clientInformation; sensors.connectionsByClient.increment(clientInformation); }
Source:
public void destroyTicketGrantingTicket(final WebContext context, final HttpTGTProfile profile) { HttpURLConnection connection = null; try { final URL endpointURL = new URL(getAuthenticator().getCasRestUrl()); final URL deleteURL = new URL(endpointURL, endpointURL.getPath() + "/" + profile.getTicketGrantingTicketId()); connection = HttpUtils.openDeleteConnection(deleteURL); final int responseCode = connection.getResponseCode(); if (responseCode != HTTP_STATUS_OK) { throw new TechnicalException("TGT delete request for `" + profile + "` failed: " + HttpUtils.buildHttpErrorMessage(connection)); } } catch (final IOException e) { throw new TechnicalException(e); } finally { HttpUtils.closeConnection(connection); } }

Target:
public void destroyTicketGrantingTicket(final WebContext context, final HttpTGTProfile profile) { HttpURLConnection connection = null; try { final URL endpointURL = new URL(getAuthenticator().getCasRestUrl()); final URL deleteURL = new URL(endpointURL, endpointURL.getPath() + "/" + profile.getTicketGrantingTicketId()); connection = HttpUtils.openDeleteConnection(deleteURL); final int responseCode = connection.getResponseCode(); if (responseCode != HttpConstants.OK) { throw new TechnicalException("TGT delete request for `" + profile + "` failed: " + HttpUtils.buildHttpErrorMessage(connection)); } } catch (final IOException e) { throw new TechnicalException(e); } finally { HttpUtils.closeConnection(connection); } }
Source:
protected StopMachineDetails<Integer> suspendAnyProvisionedMachines() { @SuppressWarnings("unchecked") MachineProvisioningLocation<MachineLocation> provisioner = entity().getAttribute(SoftwareProcess.PROVISIONING_LOCATION); if (Iterables.isEmpty(entity().getLocations())) { log.debug("No machine decommissioning necessary for " + entity() + " - no locations"); return new StopMachineDetails<>("No machine suspend necessary - no locations", 0); } if (provisioner == null) { log.debug("No machine decommissioning necessary for " + entity() + " - did not provision"); return new StopMachineDetails<>("No machine suspend necessary - did not provision", 0); } Location machine = getLocation(null); if (!(machine instanceof MachineLocation)) { log.debug("No decommissioning necessary for " + entity() + " - not a machine location (" + machine + ")"); return new StopMachineDetails<>("No machine suspend necessary - not a machine (" + machine + ")", 0); } if (!(provisioner instanceof SuspendsMachines)) { log.debug("Location provisioner ({}) cannot suspend machines", provisioner); throw new UnsupportedOperationException("Location provisioner cannot suspend machines: " + provisioner); } clearEntityLocationAttributes(machine); try { SuspendsMachines.class.cast(provisioner).suspendMachine(MachineLocation.class.cast(machine)); } catch (Throwable t) { throw Exceptions.propagate(t); } return new StopMachineDetails<>("Suspended " + machine, 1); }

Target:
protected StopMachineDetails<Integer> suspendAnyProvisionedMachines() { @SuppressWarnings("unchecked") MachineProvisioningLocation<MachineLocation> provisioner = entity().getAttribute(SoftwareProcess.PROVISIONING_LOCATION); if (Iterables.isEmpty(entity().getLocations())) { log.debug("No machine decommissioning necessary for " + entity() + " - no locations"); return new StopMachineDetails<>("No machine suspend necessary - no locations", 0); } if (provisioner == null) { log.debug("No machine decommissioning necessary for " + entity() + " - did not provision"); return new StopMachineDetails<>("No machine suspend necessary - did not provision", 0); } Location machine = getLocation(null); if (!(machine instanceof MachineLocation)) { log.debug("No decommissioning necessary for " + entity() + " - not a machine location (" + machine + ")"); return new StopMachineDetails<>("No machine suspend necessary - not a machine (" + machine + ")", 0); } if (!(provisioner instanceof SuspendsMachines)) { log.debug("Location provisioner ({}) cannot suspend machines", provisioner); throw new UnsupportedOperationException("Location provisioner cannot suspend machines: " + provisioner); } clearEntityLocationAttributes(machine); SuspendsMachines.class.cast(provisioner).suspendMachine(MachineLocation.class.cast(machine)); return new StopMachineDetails<>("Suspended " + machine, 1); }
Source:
public String visitConstant(ConstantExpression literal, Void context) { return format("%d", literal.hashCode()); }

Target:
public String visitConstant(ConstantExpression literal, Void context) { if (literal.getValue() instanceof Slice) { Slice slice = (Slice) literal.getValue(); if (slice.hasByteArray()) { return Slices.wrappedBuffer(Base64.getEncoder().encode(slice.toByteBuffer())).toStringUtf8(); } return Slices.wrappedBuffer(Base64.getEncoder().encode(slice.getBytes())).toStringUtf8(); } return literal.toString(); }
Source:
public void scheduleDownload( LeaderLocator leaderLocator ) { if ( currentJob == null || currentJob.hasCompleted() ) { synchronized ( this ) { if ( currentJob == null || currentJob.hasCompleted() ) { currentJob = new PersistentSnapshotDownloader( leaderLocator, applicationProcess, downloader, log ); jobScheduler.schedule( downloadSnapshotGroup, currentJob ); } } } }

Target:
public synchronized void scheduleDownload( LeaderLocator leaderLocator ) { if ( currentJob == null || currentJob.hasCompleted() ) { currentJob = new PersistentSnapshotDownloader( leaderLocator, applicationProcess, downloader, log, downloaderPauseStrategy ); jobScheduler.schedule( downloadSnapshot, currentJob ); } }
Source:
public void clear(IntSet segments) { Connection conn = null; PreparedStatement ps = null; try { String sql = tableManager.getDeleteRowsSqlForSegments(segments.size()); conn = connectionFactory.getConnection(); ps = conn.prepareStatement(sql); int offset = 0; for (PrimitiveIterator.OfInt segIter = segments.iterator(); segIter.hasNext(); ) { ps.setInt(++offset, segIter.nextInt()); } int result = ps.executeUpdate(); if (log.isTraceEnabled()) { log.tracef("Successfully removed %d rows.", result); } } catch (SQLException ex) { log.failedClearingJdbcCacheStore(ex); throw new PersistenceException("Failed clearing cache store", ex); } finally { JdbcUtil.safeClose(ps); connectionFactory.releaseConnection(conn); } }

Target:
public void clear(IntSet segments) { Connection conn = null; PreparedStatement ps = null; try { String sql = tableManager.getDeleteRowsSqlForSegments(segments.size()); conn = connectionFactory.getConnection(); ps = conn.prepareStatement(sql); int offset = 0; for (PrimitiveIterator.OfInt segIter = segments.iterator(); segIter.hasNext(); ) { ps.setInt(++offset, segIter.nextInt()); } int result = ps.executeUpdate(); if (log.isTraceEnabled()) { log.tracef("Successfully removed %d rows.", result); } } catch (SQLException ex) { log.failedClearingJdbcCacheStore(ex); throw new PersistenceException("Failed clearing cache store when using segments " + segments, ex); } finally { JdbcUtil.safeClose(ps); connectionFactory.releaseConnection(conn); } }
Source:
private void migrateV1FilesToV2Location(FilePersistence filePersistence, Migration migration) { for (Migration.FileMetadata fileMetadata : migration.getFileMetadata()) { filePersistence.create(fileMetadata.newFileLocation(), fileMetadata.fileSize()); FileInputStream inputStream = null; try { inputStream = new FileInputStream(new File(fileMetadata.originalFileLocation().path())); byte[] bytes = new byte[RANDOMLY_CHOSEN_BUFFER_SIZE_THAT_SEEMS_TO_WORK]; int readLast = 0; while (readLast != -1) { readLast = inputStream.read(bytes); if (readLast != 0 && readLast != -1) { filePersistence.write(bytes, 0, readLast); bytes = new byte[RANDOMLY_CHOSEN_BUFFER_SIZE_THAT_SEEMS_TO_WORK]; } } } catch (IOException e) { Log.e(getClass().getSimpleName(), e.getMessage()); } finally { try { filePersistence.close(); if (inputStream != null) { inputStream.close(); } } catch (IOException e) { Log.e(getClass().getSimpleName(), e.getMessage()); } } } }

Target:
private void migrateV1FilesToV2Location(FilePersistence filePersistence, Migration migration) { for (Migration.FileMetadata fileMetadata : migration.getFileMetadata()) { filePersistence.create(fileMetadata.newFileLocation(), fileMetadata.fileSize()); FileInputStream inputStream = null; try { inputStream = new FileInputStream(new File(fileMetadata.originalFileLocation().path())); byte[] bytes = new byte[RANDOMLY_CHOSEN_BUFFER_SIZE_THAT_SEEMS_TO_WORK]; int readLast = 0; while (readLast != -1) { readLast = inputStream.read(bytes); if (readLast != 0 && readLast != -1) { filePersistence.write(bytes, 0, readLast); } } } catch (IOException e) { Logger.e(e.getMessage()); } finally { try { filePersistence.close(); if (inputStream != null) { inputStream.close(); } } catch (IOException e) { Logger.e(e.getMessage()); } } } }
Source:
public void testWriteListener() throws Exception { applicationContext = new SpringApplicationBuilder() .sources(getConfigurations(BatchExecutionEventTests.ItemWriteEventsListenerBinding.class)) .build().run( getCommandLineParams("--spring.cloud.stream.bindings.item-write-events.destination=item-write-events-foobar")); assertTrue(itemWriteEventsLatch.await(1, TimeUnit.SECONDS)); }

Target:
public void testWriteListener() throws Exception { testListener("--spring.cloud.stream.bindings.item-write-events.destination=item-write-events-foobar", itemWriteEventsLatch, BatchExecutionEventTests.ItemWriteEventsListenerBinding.class); }
Source:
public void testDownloadInMultipleThreads() throws IOException, InterruptedException { FileUtils.deleteDirectory(targetMavenDir); final CountDownLatch latch = new CountDownLatch(1); createThreadWithDownload(latch).start(); createThreadWithDownload(latch).start(); latch.countDown(); downloadSWR300Alpha1(); String expMsg = "Resolver: downloading Maven binaries from"; Matcher matcher = Pattern.compile(expMsg).matcher(systemOutRule.getLog()); assertThat(matcher.find()).as(String.format( "The log should contain one occurrence of message \"%s\" but none was found. For more information see the log", expMsg)) .isTrue(); assertThat(matcher.find()).as(String.format( "The log should contain only one occurrence of message \"%s\" but more than one was found. For more information see the log", expMsg)).isFalse(); }

Target:
public void testDownloadInMultipleThreads() throws IOException, InterruptedException { FileUtils.deleteDirectory(targetMavenDir); CountDownLatch startLatch = new CountDownLatch(1); CountDownLatch stopLatch = new CountDownLatch(3); createThreadWithDownload(startLatch, stopLatch).start(); createThreadWithDownload(startLatch, stopLatch).start(); createThreadWithDownload(startLatch, stopLatch).start(); startLatch.countDown(); stopLatch.await(20, TimeUnit.SECONDS); String expMsg = "Resolver: downloading Maven binaries from"; Matcher matcher = Pattern.compile(expMsg).matcher(systemOutRule.getLog()); assertThat(matcher.find()).as(String.format( "The log should contain one occurrence of message \"%s\" but none was found. For more information see the log", expMsg)) .isTrue(); assertThat(matcher.find()).as(String.format( "The log should contain only one occurrence of message \"%s\" but more than one was found. For more information see the log", expMsg)).isFalse(); }
Source:
public void testProjectUpdatesRowType() { final RelBuilder builder = RelBuilder.create(RelBuilderTest.config().build()); final RelNode root = builder .scan("EMP") .project( builder.field("DEPTNO"), builder.field("SAL")) .build(); final RelDataType type1 = root.getRowType(); final RelNode rootWithCast = builder .scan("EMP") .project( builder.cast(builder.field("DEPTNO"), SqlTypeName.VARCHAR), builder.cast(builder.field("SAL"), SqlTypeName.VARCHAR)) .build(); final RelDataType type2 = rootWithCast.getRowType(); assertThat(type1, not(type2)); final RelNode rootWithCastViaRexShuttle = root.accept(new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef inputRef) { return builder.cast(inputRef, SqlTypeName.VARCHAR); } }); final RelDataType type3 = rootWithCastViaRexShuttle.getRowType(); assertThat(type2, is(type3)); }

Target:
public void testProjectUpdatesRowType() { final RelBuilder builder = RelBuilder.create(RelBuilderTest.config().build()); final RelNode root = builder .scan("EMP") .project( builder.field("DEPTNO"), builder.field("SAL")) .build(); final RelNode rootWithCast = builder .scan("EMP") .project( builder.cast(builder.field("DEPTNO"), SqlTypeName.VARCHAR), builder.cast(builder.field("SAL"), SqlTypeName.VARCHAR)) .build(); final RelDataType type = rootWithCast.getRowType(); final RelNode rootWithCastViaRexShuttle = root.accept(new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef inputRef) { return builder.cast(inputRef, SqlTypeName.VARCHAR); } }); final RelDataType type2 = rootWithCastViaRexShuttle.getRowType(); assertThat(type, is(type2)); }
Source:
public UnknownTypeJsonAccessor path(String dotSeparatedPath) { String[] components = DOT_REGEX.split( dotSeparatedPath ); String leaf = components[components.length - 1]; JsonObjectAccessor parent = this; for ( int i = 0; i < components.length - 1; i++ ) { parent = parent.property( components[i] ).asObject(); } return parent.property( leaf ); }

Target:
public UnknownTypeJsonAccessor path(String dotSeparatedPath) { Contracts.assertNotNullNorEmpty( dotSeparatedPath, "dotSeparatedPath" ); String[] components = DOT_REGEX.split( dotSeparatedPath ); String leaf = components[components.length - 1]; JsonObjectAccessor parent = this; for ( int i = 0; i < components.length - 1; i++ ) { parent = parent.property( components[i] ).asObject(); } return parent.property( leaf ); }
Source:
public void testListOfTokens() throws Exception { Grammar.NonTerminalId ntistart = new Grammar.NonTerminalId("StartNT"); Grammar.StateId stistart = new Grammar.StateId("StartState"); Grammar.StateId stiend = new Grammar.StateId("EndState"); Grammar.NonTerminal nt1 = new Grammar.NonTerminal(ntistart, stistart, new Grammar.State.OrderingInfo(0), stiend, new Grammar.State.OrderingInfo(100)); Grammar.RegExState res1 = new Grammar.RegExState(new Grammar.StateId("RegExStid"), nt1, new Grammar.State.OrderingInfo(1), Pattern.compile("[a-zA-Z0-9]")); nt1.entryState.next.add(res1); nt1.entryState.next.add(nt1.exitState); res1.next.add(nt1.exitState); res1.next.add(res1); { Term result = new Parser(new ParseState("abc")).parse(nt1, 0); Term expected = amb(klist(amb(klist(Token.kAppOf("K", "a"), Token.kAppOf("K", "b"), Token.kAppOf("K", "c"))))); assertEquals("Single Token check: ", expected, result); } { Term result = new Parser(new ParseState("")).parse(nt1, 0); Term expected = amb(klist(amb(klist()))); assertEquals("Single Token check: ", expected, result); } { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 100; i++) { sb.append('a'); } for (int j = 0; j < 20; j++) { long start = getCpuTime(); for (int i = 0; i < 100; i++) { Term result = new Parser(new ParseState(sb.toString())).parse(nt1, 0); } long end = getCpuTime(); System.out.println("Time: " + ((end - start) / 1000000.0)); } } assertEquals("Expected Nullable NTs", 1, NullabilityCheck.getReachableNullableNT(nt1).size()); }

Target:
public void testListOfTokens() throws Exception { Grammar.NonTerminalId ntistart = new Grammar.NonTerminalId("StartNT"); Grammar.StateId stistart = new Grammar.StateId("StartState"); Grammar.StateId stiend = new Grammar.StateId("EndState"); Grammar.NonTerminal nt1 = new Grammar.NonTerminal(ntistart, stistart, new Grammar.State.OrderingInfo(0), stiend, new Grammar.State.OrderingInfo(100)); Grammar.RegExState res1 = new Grammar.RegExState(new Grammar.StateId("RegExStid"), nt1, new Grammar.State.OrderingInfo(1), Pattern.compile("[a-zA-Z0-9]")); nt1.entryState.next.add(res1); nt1.entryState.next.add(nt1.exitState); res1.next.add(nt1.exitState); res1.next.add(res1); { Term result = new Parser(new ParseState("abc")).parse(nt1, 0); Term expected = amb(klist(amb(klist(Token.kAppOf("K", "a"), Token.kAppOf("K", "b"), Token.kAppOf("K", "c"))))); Assert.assertEquals("Single Token check: ", expected, result); } { Term result = new Parser(new ParseState("")).parse(nt1, 0); Term expected = amb(klist(amb(klist()))); Assert.assertEquals("Single Token check: ", expected, result); } { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 10; i++) { sb.append('a'); } for (int j = 0; j < 1; j++) { long start = getCpuTime(); for (int i = 0; i < 100; i++) { Term result = new Parser(new ParseState(sb.toString())).parse(nt1, 0); } long end = getCpuTime(); } } Assert.assertEquals("Expected Nullable NTs", nt1, NullabilityCheck.getReachableNullableNT(nt1).iterator().next()); }
Source:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } ElasticsearchColumnMetadata that = (ElasticsearchColumnMetadata) o; return jsonPath.equals(that.jsonPath) && jsonType.equals(that.jsonType) && ordinalPosition == that.ordinalPosition; }

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } ElasticsearchColumnMetadata that = (ElasticsearchColumnMetadata) o; return jsonPath.equals(that.jsonPath) && jsonType.equals(that.jsonType) && ordinalPosition == that.ordinalPosition && isList == that.isList; }
Source:
public Tag(int accountId, int id, int internal, String name) { this.accountId = checkNotNull(accountId, "accountId"); this.id = checkNotNull(id, "id"); this.internal = checkNotNull(internal, "internal"); this.name = checkNotNull(name, "name"); }

Target:
public Tag(int accountId, int id, int internal, String name) { this.accountId = accountId; this.id = id; this.internal = internal; this.name = checkNotNull(name, "name"); }
Source:
public void testCurrentSchemaPropertyNotVisibilityTableInsideFunction() throws SQLException { testCurrentSchemaPropertyVisibilityTableDuringFunctionCreation(); Properties properties = new Properties(); properties.setProperty(PGProperty.CURRENT_SCHEMA.getName(), "public,schema2"); Connection connection = TestUtil.openDB(properties); expectedEx.expect(PSQLException.class); expectedEx.expectMessage("ERROR: relation \"check_table\" does not exist"); TestUtil.execute("select check_fun()", connection); connection.close(); }

Target:
public void testCurrentSchemaPropertyNotVisibilityTableInsideFunction() throws SQLException { testCurrentSchemaPropertyVisibilityTableDuringFunctionCreation(); Properties properties = new Properties(); properties.setProperty(PGProperty.CURRENT_SCHEMA.getName(), "public,schema2"); try (Connection connection = TestUtil.openDB(properties)) { TestUtil.execute("select check_fun()", connection); } catch (PSQLException e) { String sqlState = e.getSQLState(); String message = e.getMessage(); assertThat("Test call function in schema 'schema2' and this function uses table \"check_table\" " + "from schema 'schema1'. We expect here sql error code - " + PSQLState.UNDEFINED_TABLE + ", " + "because search_path does not contains schema 'schema1' and postgres does not see table \"check_table\".", sqlState, equalTo(PSQLState.UNDEFINED_TABLE.getState()) ); assertThat( "Test call function in schema 'schema2' and this function uses table \"check_table\" " + "from schema 'schema1'. We expect here that sql error message will be contains \"check_table\", because " + " search_path does not contains schema 'schema1' and postgres does not see table \"check_table\"", message, containsString("\"check_table\"") ); } }
Source:
void hookEvents () { if ((style & SWT.BALLOON) != 0) { if (!OS.GTK3) { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true); } else { if (OS.GTK_VERSION >= OS.VERSION (3, 9, 0)) { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT_INVERSE], 0, display.getClosure (EXPOSE_EVENT_INVERSE), true); } else { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true); } } OS.gtk_widget_add_events (handle, OS.GDK_BUTTON_PRESS_MASK); OS.g_signal_connect_closure (handle, OS.button_press_event, display.getClosure (BUTTON_PRESS_EVENT), false); } }

Target:
void hookEvents () { if ((style & SWT.BALLOON) != 0) { if (!OS.GTK3) { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true); } else { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true); if (OS.GTK_VERSION >= OS.VERSION (3, 9, 0)) { OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT_INVERSE], 0, display.getClosure (EXPOSE_EVENT_INVERSE), true); } } OS.gtk_widget_add_events (handle, OS.GDK_BUTTON_PRESS_MASK); OS.g_signal_connect_closure (handle, OS.button_press_event, display.getClosure (BUTTON_PRESS_EVENT), false); } }
Source:
public void doAuthorise_shouldRespondWith3dsResponseForEpdq3dsOrders() throws XMLUnmarshallerException { providerWillRequireEpdq3ds(); GatewayResponse response = cardAuthorisationService.doAuthorise(charge.getExternalId(), aValidAuthorisationDetails()); assertThat(response.isSuccessful(), is(true)); assertThat(charge.getStatus(), is(AUTHORISATION_3DS_REQUIRED.getValue())); verify(mockedChargeEventDao).persistChargeEventOf(charge, Optional.empty()); assertThat(charge.get3dsDetails().getHtmlOut(), is(notNullValue())); Card3dsEntity card3ds = paymentRequest.getChargeTransaction().getCard3ds(); assertThat(card3ds.getIssuerUrl(), is(nullValue())); assertThat(card3ds.getPaRequest(), is(nullValue())); assertThat(card3ds.getHtmlOut(), is(notNullValue())); }

Target:
public void doAuthorise_shouldRespondWith3dsResponseForEpdq3dsOrders() { epdqProviderWillRequire3ds(); GatewayResponse response = cardAuthorisationService.doAuthorise(charge.getExternalId(), aValidAuthorisationDetails()); assertThat(response.isSuccessful(), is(true)); assertThat(charge.getStatus(), is(AUTHORISATION_3DS_REQUIRED.getValue())); verify(mockedChargeEventDao).persistChargeEventOf(charge, Optional.empty()); assertThat(charge.get3dsDetails().getHtmlOut(), is(notNullValue())); Card3dsEntity card3ds = paymentRequest.getChargeTransaction().getCard3ds(); assertThat(card3ds.getIssuerUrl(), is(nullValue())); assertThat(card3ds.getPaRequest(), is(nullValue())); assertThat(card3ds.getHtmlOut(), is("Base64encodedHtmlForm")); }
Source:
private void validateEntities(List<Entity> entities) throws FalconException { for (Entity entity : entities) { super.validate(entity); } }

Target:
private void validateEntities(List<Entity> entities) throws FalconException { for (Entity entity : entities) { if (!EntityType.FEED.equals(entity.getEntityType()) && !EntityType.FEED.equals(entity.getEntityType())) { LOG.error("Cluster entity is not allowed for submission via submitEntities: {}", entity.getName()); throw new FalconException("Cluster entity is not allowed for submission in extensions submission"); } super.validate(entity); } }
Source:
private List<VmAnalyzer> analyzeVms( List<Pair<VM, VdsmVm>> monitoredVms, long fetchTime, VdsManager vdsManager, boolean updateStatistics) { VmAnalyzerFactory vmAnalyzerFactory = getVmAnalyzerFactory(vdsManager, updateStatistics); List<VmAnalyzer> vmAnalyzers = new ArrayList<>(monitoredVms.size()); monitoredVms.forEach(vm -> { if (shouldAnalyzeVm(vm, fetchTime, vdsManager.getVdsId())) { try { VmAnalyzer vmAnalyzer = vmAnalyzerFactory.getVmAnalyzer(vm); vmAnalyzer.analyze(); vmAnalyzers.add(vmAnalyzer); } catch (RuntimeException ex) { Guid vmId = getVmId(vm.getFirst(), vm.getSecond()); VmManager vmManager = resourceManager.getVmManager(vmId); vmManager.unlock(); String vmName = vm.getFirst() != null ? vm.getFirst().getName() : ""; log.error("Failed during monitoring vm {}, error is: {}", vmName, ex); log.error("Exception:", ex); } } }); return vmAnalyzers; }

Target:
private List<VmAnalyzer> analyzeVms( List<Pair<VM, VdsmVm>> monitoredVms, long fetchTime, VdsManager vdsManager, boolean updateStatistics) { VmAnalyzerFactory vmAnalyzerFactory = getVmAnalyzerFactory(vdsManager, updateStatistics); List<VmAnalyzer> vmAnalyzers = new ArrayList<>(monitoredVms.size()); monitoredVms.forEach(vm -> { if (shouldAnalyzeVm(vm, fetchTime, vdsManager.getVdsId())) { try { VmAnalyzer vmAnalyzer = vmAnalyzerFactory.getVmAnalyzer(vm); vmAnalyzer.analyze(); vmAnalyzers.add(vmAnalyzer); } catch (RuntimeException ex) { Guid vmId = getVmId(vm.getFirst(), vm.getSecond()); VmManager vmManager = resourceManager.getVmManager(vmId); vmManager.unlock(); String vmName = vm.getFirst() != null ? vm.getFirst().getName() : ""; log.error("Failed during monitoring vm: ({}), error is: {}", vmName, vmId, ex); log.error("Exception:", ex); } } }); return vmAnalyzers; }
Source:
public Object getProperty( String key, Object defaultValue ) { if ( null == key ) { throw new IllegalArgumentException( "(null) property key is not allowed" ); } try ( Statement ignore = actions.statement() ) { KernelTransaction transaction = actions.kernelTransaction(); CursorFactory cursors = transaction.cursors(); try ( NodeCursor nodes = cursors.allocateNodeCursor(); PropertyCursor properties = cursors.allocatePropertyCursor() ) { int propertyKey = transaction.token().propertyKey( key ); if ( propertyKey == KeyReadOperations.NO_SUCH_PROPERTY_KEY ) { return defaultValue; } transaction.dataRead().singleNode( nodeId, nodes ); if ( !nodes.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.NODE, nodeId ) ); } nodes.properties( properties ); while ( properties.next() ) { if ( propertyKey == properties.propertyKey() ) { Value value = properties.propertyValue(); return value == Values.NO_VALUE ? defaultValue : value.asObjectCopy(); } } return defaultValue; } } }

Target:
public Object getProperty( String key, Object defaultValue ) { if ( null == key ) { throw new IllegalArgumentException( "(null) property key is not allowed" ); } try ( Statement ignore = actions.statement() ) { KernelTransaction transaction = actions.kernelTransaction(); int propertyKey = transaction.token().propertyKey( key ); if ( propertyKey == KeyReadOperations.NO_SUCH_PROPERTY_KEY ) { return defaultValue; } CursorFactory cursors = transaction.cursors(); try ( NodeCursor nodes = cursors.allocateNodeCursor(); PropertyCursor properties = cursors.allocatePropertyCursor() ) { transaction.dataRead().singleNode( nodeId, nodes ); if ( !nodes.next() ) { throw new NotFoundException( new EntityNotFoundException( EntityType.NODE, nodeId ) ); } nodes.properties( properties ); while ( properties.next() ) { if ( propertyKey == properties.propertyKey() ) { Value value = properties.propertyValue(); return value == Values.NO_VALUE ? defaultValue : value.asObjectCopy(); } } return defaultValue; } } }
Source:
public void run() { updateTimeTrackingBeforeRun(); if (missedStartTime() && isScheduled()) { onChoreMissedStartTime(); if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " missed its start time"); } else if (stopper.isStopped() || !isScheduled()) { cancel(false); cleanup(); if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " was stopped"); } else { try { long start = 0; if (LOG.isDebugEnabled()) { start = System.nanoTime(); } if (!initialChoreComplete) { initialChoreComplete = initialChore(); } else { chore(); } if (LOG.isDebugEnabled()) { long end = System.nanoTime(); LOG.debug("{} execution time: ms.", getName(), TimeUnit.NANOSECONDS.toMillis(end - start)); } } catch (Throwable t) { if (LOG.isErrorEnabled()) LOG.error("Caught error", t); if (this.stopper.isStopped()) { cancel(false); cleanup(); } } } }

Target:
public void run() { updateTimeTrackingBeforeRun(); if (missedStartTime() && isScheduled()) { onChoreMissedStartTime(); if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " missed its start time"); } else if (stopper.isStopped() || !isScheduled()) { cancel(false); cleanup(); if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " was stopped"); } else { try { long start = 0; if (LOG.isDebugEnabled()) { start = System.nanoTime(); } if (!initialChoreComplete) { initialChoreComplete = initialChore(); } else { chore(); } if (LOG.isDebugEnabled() && start > 0) { long end = System.nanoTime(); LOG.debug("{} execution time: ms.", getName(), TimeUnit.NANOSECONDS.toMillis(end - start)); } } catch (Throwable t) { if (LOG.isErrorEnabled()) LOG.error("Caught error", t); if (this.stopper.isStopped()) { cancel(false); cleanup(); } } } }
Source:
public BufferAggregator factorizeBuffered(final ColumnSelectorFactory metricFactory) { if (metricColumns == null) { final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector = metricFactory .makeColumnValueSelector(fieldName); if (selector instanceof NilColumnValueSelector) { return new ArrayOfDoublesSketchNoOpBufferAggregator(numberOfValues); } return new ArrayOfDoublesSketchMergeBufferAggregator(selector, nominalEntries, numberOfValues, getMaxIntermediateSize()); } final DimensionSelector keySelector = metricFactory .makeDimensionSelector(new DefaultDimensionSpec(fieldName, fieldName)); if (keySelector instanceof NullDimensionSelector) { return new ArrayOfDoublesSketchNoOpBufferAggregator(numberOfValues); } final List<BaseDoubleColumnValueSelector> valueSelectors = new ArrayList<>(); for (final String column: metricColumns) { final BaseDoubleColumnValueSelector valueSelector = metricFactory.makeColumnValueSelector(column); valueSelectors.add(valueSelector); } return new ArrayOfDoublesSketchBuildBufferAggregator(keySelector, valueSelectors, nominalEntries, getMaxIntermediateSize()); }

Target:
public BufferAggregator factorizeBuffered(final ColumnSelectorFactory metricFactory) { if (metricColumns == null) { final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector = metricFactory .makeColumnValueSelector(fieldName); if (selector instanceof NilColumnValueSelector) { return new ArrayOfDoublesSketchNoOpBufferAggregator(numberOfValues); } return new ArrayOfDoublesSketchMergeBufferAggregator( selector, nominalEntries, numberOfValues, getMaxIntermediateSize() ); } final DimensionSelector keySelector = metricFactory .makeDimensionSelector(new DefaultDimensionSpec(fieldName, fieldName)); if (DimensionSelectorUtils.isNilSelector(keySelector)) { return new ArrayOfDoublesSketchNoOpBufferAggregator(numberOfValues); } final List<BaseDoubleColumnValueSelector> valueSelectors = new ArrayList<>(); for (final String column : metricColumns) { final BaseDoubleColumnValueSelector valueSelector = metricFactory.makeColumnValueSelector(column); valueSelectors.add(valueSelector); } return new ArrayOfDoublesSketchBuildBufferAggregator( keySelector, valueSelectors, nominalEntries, getMaxIntermediateSize() ); }
Source:
private boolean isTopLevelRepresentationRemoval(Notification notification) { Object notifier = notification.getNotifier(); boolean isResourceContentChange = notifier instanceof Resource && notification.getFeatureID(Resource.class) == Resource.RESOURCE__CONTENTS; final boolean isRepresentationRemoval; if (notification.getEventType() == Notification.REMOVE && notification.getOldValue() instanceof DRepresentation) { isRepresentationRemoval = true; } else if (notification.getEventType() == Notification.REMOVE_MANY) { Collection<?> removed = (Collection<?>) notification.getOldValue(); isRepresentationRemoval = Iterables.all(removed, Predicates.instanceOf(DRepresentation.class)); } else { isRepresentationRemoval = false; } return isResourceContentChange && isRepresentationRemoval; }

Target:
public static boolean isTopLevelRepresentationRemoval(Notification notification) { Object notifier = notification.getNotifier(); boolean isResourceContentChange = notifier instanceof Resource && notification.getFeatureID(Resource.class) == Resource.RESOURCE__CONTENTS; final boolean isRepresentationRemoval; if (notification.getEventType() == Notification.REMOVE && notification.getOldValue() instanceof DRepresentation) { isRepresentationRemoval = true; } else if (notification.getEventType() == Notification.REMOVE_MANY) { Collection<?> removed = (Collection<?>) notification.getOldValue(); isRepresentationRemoval = Iterables.all(removed, Predicates.instanceOf(DRepresentation.class)); } else { isRepresentationRemoval = false; } return isResourceContentChange && isRepresentationRemoval; }
Source:
public String getString(String dataType, BigInteger address, MemoryByte[] data) { boolean invalid = false; String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); for (MemoryByte d : data) { if (!d.isReadable()) { invalid = true; break; } } if (invalid) { StringBuilder strBuf = new StringBuilder(); for (int i=0; i<data.length; i++) { strBuf.append(paddedStr); } return strBuf.toString(); } int columnSize = getBytesPerColumn(); int endianess = getDisplayEndianess(); if (endianess == RenderingsUtil.ENDIANESS_UNKNOWN) { endianess = getBytesEndianess(data); } byte[] byteArray = new byte[data.length]; for (int i=0; i<byteArray.length;i ++) { byteArray[i] = data[i].getValue(); } if (RenderingsUtil.ENDIANESS_UNKNOWN == endianess) { StringBuilder strBuf = new StringBuilder(); for (int i=0; i<byteArray.length; i++) { strBuf.append(paddedStr); } return strBuf.toString(); } return convertToString(byteArray, columnSize, endianess); }

Target:
public String getString(String dataType, BigInteger address, MemoryByte[] data) { boolean invalid = false; String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); for (MemoryByte memByte : data) { if (!memByte.isReadable()) { invalid = true; break; } } if (invalid) { StringBuilder strBuf = new StringBuilder(); for (int i=0; i<data.length; i++) { strBuf.append(paddedStr); } return strBuf.toString(); } int columnSize = getBytesPerColumn(); int endianess = getDisplayEndianess(); if (endianess == RenderingsUtil.ENDIANESS_UNKNOWN) { endianess = getBytesEndianess(data); } byte[] byteArray = new byte[data.length]; for (int i=0; i<byteArray.length;i ++) { byteArray[i] = data[i].getValue(); } if (RenderingsUtil.ENDIANESS_UNKNOWN == endianess) { StringBuilder strBuf = new StringBuilder(); for (int i=0; i<byteArray.length; i++) { strBuf.append(paddedStr); } return strBuf.toString(); } return convertToString(byteArray, columnSize, endianess); }
Source:
public void testDeserializationOfSingleJobExecution() throws IOException { final ObjectMapper objectMapper = DataFlowTemplate.prepareObjectMapper(new ObjectMapper()); final InputStream inputStream = JobExecutionDeserializationTests.class .getResourceAsStream("/SingleJobExecutionJson.txt"); final String json = new String(StreamUtils.copyToByteArray(inputStream)); final JobExecutionResource jobExecutionInfoResource = objectMapper.readValue(json, JobExecutionResource.class); assertNotNull(jobExecutionInfoResource); assertEquals(Long.valueOf(1), jobExecutionInfoResource.getJobId()); assertEquals("ff.job", jobExecutionInfoResource.getName()); assertEquals("COMPLETED", jobExecutionInfoResource.getJobExecution().getStatus().name()); assertEquals(1, jobExecutionInfoResource.getJobExecution().getStepExecutions().size()); StepExecution stepExecution = jobExecutionInfoResource.getJobExecution().getStepExecutions().iterator().next(); assertNotNull(stepExecution); ExecutionContext stepExecutionExecutionContext = stepExecution.getExecutionContext(); assertNotNull(stepExecutionExecutionContext); assertEquals(2, stepExecutionExecutionContext.size()); }

Target:
public void testDeserializationOfSingleJobExecution() throws IOException { final ObjectMapper objectMapper = DataFlowTemplate.prepareObjectMapper(new ObjectMapper()); final InputStream inputStream = JobExecutionDeserializationTests.class .getResourceAsStream("/SingleJobExecutionJson.txt"); final String json = new String(StreamUtils.copyToByteArray(inputStream)); final JobExecutionResource jobExecutionInfoResource = objectMapper.readValue(json, JobExecutionResource.class); assertNotNull(jobExecutionInfoResource); assertEquals(Long.valueOf(1), jobExecutionInfoResource.getJobId()); assertEquals("ff.job", jobExecutionInfoResource.getName()); assertEquals("COMPLETED", jobExecutionInfoResource.getJobExecution().getStatus().name()); assertEquals(1, jobExecutionInfoResource.getJobExecution().getStepExecutions().size()); final StepExecution stepExecution = jobExecutionInfoResource.getJobExecution().getStepExecutions().iterator().next(); assertNotNull(stepExecution); final ExecutionContext stepExecutionExecutionContext = stepExecution.getExecutionContext(); assertNotNull(stepExecutionExecutionContext); assertEquals(2, stepExecutionExecutionContext.size()); }
Source:
private String analyzerName(DocumentFieldMetadata fieldMetadata) { AnalyzerReference analyzer = fieldMetadata.getAnalyzer(); if ( analyzer.is( RemoteAnalyzerReference.class ) ) { return analyzer.unwrap( RemoteAnalyzerReference.class ).getName(); } return null; }

Target:
private String analyzerName(DocumentFieldMetadata fieldMetadata) { AnalyzerReference analyzer = fieldMetadata.getAnalyzer(); if ( analyzer.is( RemoteAnalyzerReference.class ) ) { return analyzer.unwrap( RemoteAnalyzerReference.class ).getName(); } LOG.analyzerIsNotRemote( String.valueOf( analyzer ) ); return null; }
Source:
public Predicate<ChangeData> project(String name) { Project project = args.projectCache.get(new Project.NameKey(name)).getProject(); return new ProjectPredicate(args.dbProvider, project.getId()); }

Target:
public Predicate<ChangeData> project(String name) { if (name.startsWith("^")) return new RegexProjectPredicate(args.dbProvider, args.projectCache, name); final ProjectState projectState = args.projectCache.get(new Project.NameKey(name)); if (projectState == null) { return new NotMatchingPredicate<ChangeData>(FIELD_PROJECT, name); } final Project project = projectState.getProject(); return new ProjectPredicate(args.dbProvider, project.getId(), name); }
Source:
public long internal_new_GC (GCData data) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (type != SWT.BITMAP || memGC != null) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } double sx[] =new double[1]; double sy[] =new double[1]; Cairo.cairo_surface_get_device_scale(surface, sx, sy); long gc = Cairo.cairo_create(surface); if (data != null) { int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if ((data.style & mask) == 0) { data.style |= SWT.LEFT_TO_RIGHT; } else { if ((data.style & SWT.RIGHT_TO_LEFT) != 0) { data.style |= SWT.MIRRORED; } } data.device = device; data.drawable = pixmap; if (GTK.GTK3) { data.foregroundRGBA = device.COLOR_BLACK.handleRGBA; data.backgroundRGBA = device.COLOR_WHITE.handleRGBA; } else { data.background = device.COLOR_WHITE.handle; data.foreground = device.COLOR_BLACK.handle; } data.font = device.systemFont; data.image = this; } return gc; }

Target:
public long internal_new_GC (GCData data) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (type != SWT.BITMAP || memGC != null) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } long gc = Cairo.cairo_create(surface); if (data != null) { int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if ((data.style & mask) == 0) { data.style |= SWT.LEFT_TO_RIGHT; } else { if ((data.style & SWT.RIGHT_TO_LEFT) != 0) { data.style |= SWT.MIRRORED; } } data.device = device; data.drawable = pixmap; if (GTK.GTK3) { data.foregroundRGBA = device.COLOR_BLACK.handleRGBA; data.backgroundRGBA = device.COLOR_WHITE.handleRGBA; } else { data.background = device.COLOR_WHITE.handle; data.foreground = device.COLOR_BLACK.handle; } data.font = device.systemFont; data.image = this; } return gc; }
Source:
public void test_unmodifiableMap_LinkedHashMap() { LinkedHashMap<String, Integer> smallMap = new LinkedHashMap<String, Integer>(); for (int counter = 0; counter < 100; counter++) { Integer object = objArray[counter]; smallMap.put(object.toString(), object); } new Support_MapTest("", smallMap).runTest(); }

Target:
public void test_unmodifiableMap_LinkedHashMap() { LinkedHashMap<String, Integer> smallMap = new LinkedHashMap<String, Integer>(); for (int i = 0; i < 100; i++) { Integer object = objArray[i]; smallMap.put(object.toString(), object); } new MapTestSupport(smallMap).runTest(); }
Source:
public double getLocationRatio(ITmfLocation<?> location) { final CtfLocation curLocation = (CtfLocation) location; CtfIterator iterator = CtfIteratorManager.getIterator(this, ctx); ctx.setLocation(curLocation); ctx.seek(curLocation.getLocation()); long currentTime = ((Long)ctx.getLocation().getLocation()); return ((double) currentTime - iterator.getStartTime()) / (iterator.getEndTime() - iterator.getStartTime()); }

Target:
public double getLocationRatio(ITmfLocation<?> location) { final CtfLocation curLocation = (CtfLocation) location; CtfIterator iterator = getIterator(); ctx.setLocation(curLocation); ctx.seek(curLocation.getLocation()); long currentTime = ((Long)ctx.getLocation().getLocation()); return ((double) currentTime - iterator.getStartTime()) / (iterator.getEndTime() - iterator.getStartTime()); }
Source:
public void start() throws CacheLoaderException { super.start(); try { validateConfiguration(config, cache.getCacheConfiguration()); String location = config.getLocation(); if (location == null || location.trim().length() == 0) location = "Infinispan-SingleFileCacheStore"; File dir = new File(location); if (!dir.exists() && !dir.mkdirs()) throw log.directoryCannotBeCreated(dir.getAbsolutePath()); File f = new File(location, cache.getName() + ".dat"); file = new RandomAccessFile(f, "rw").getChannel(); final Map<Object, FileEntry> entryMap; if (config.getMaxKeysInMemory() > 0) entryMap = new LinkedHashMap<Object, FileEntry>(16, 0.75f, true); else entryMap = new HashMap<Object, FileEntry>(); entries = Collections.synchronizedMap(entryMap); freeList = Collections.synchronizedSortedSet(new TreeSet<FileEntry>()); byte[] header = new byte[MAGIC.length]; if (file.read(ByteBuffer.wrap(header), 0) == MAGIC.length && Arrays.equals(MAGIC, header) && cache.getCacheConfiguration().loaders().preload()) preload(); else clear(); } catch (Exception e) { throw new CacheLoaderException(e); } }

Target:
public void start() throws CacheLoaderException { super.start(); try { String location = config.getLocation(); if (location == null || location.trim().length() == 0) location = "Infinispan-SingleFileCacheStore"; File dir = new File(location); if (!dir.exists() && !dir.mkdirs()) throw log.directoryCannotBeCreated(dir.getAbsolutePath()); File f = new File(location, cache.getName() + ".dat"); file = new RandomAccessFile(f, "rw").getChannel(); final Map<Object, FileEntry> entryMap; if (config.getMaxEntries() > 0) entryMap = new LinkedHashMap<Object, FileEntry>(16, 0.75f, true); else entryMap = new HashMap<Object, FileEntry>(); entries = Collections.synchronizedMap(entryMap); freeList = Collections.synchronizedSortedSet(new TreeSet<FileEntry>()); byte[] header = new byte[MAGIC.length]; if (file.read(ByteBuffer.wrap(header), 0) == MAGIC.length && Arrays.equals(MAGIC, header)) rebuildIndex(); else clear(); } catch (Exception e) { throw new CacheLoaderException(e); } }
Source:
public void messageReceived(final String message) { final PlayerName from = MessageContext.getSender().getPlayerName(); if (isIgnored(from)) { return; } chatHistory.add(new ChatMessage(message, from)); for (final IChatListener listener : listeners) { listener.addMessage(message, from); } while (chatHistory.size() > 1000) { chatHistory.remove(0); } }

Target:
public void messageReceived(final String message) { final PlayerName from = MessageContext.getSender().getPlayerName(); if (isIgnored(from)) { return; } chatHistory.add(new ChatMessage(message, from)); for (final IChatListener listener : listeners) { listener.addMessage(message, from); } }