Skip to content

Commit

Permalink
#1644 move closer
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 15, 2022
1 parent a890c71 commit 7ef2c0f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/io/LoggingInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public int read(final byte[] buf, final int offset, final int len)
final Instant start = Instant.now();
final int byts = this.origin.read(buf, offset, len);
final Instant end = Instant.now();
final long millis = Duration.between(start, end).toMillis();
if (byts > 0) {
this.bytes.getAndAdd(byts);
final long millis = Duration.between(start, end).toMillis();
this.time.getAndAdd(millis);
}
final UncheckedText msg = new UncheckedText(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/io/LoggingOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public void write(final byte[] buf, final int offset,
final Instant start = Instant.now();
this.origin.write(buf, offset, len);
final Instant end = Instant.now();
final long millis = Duration.between(start, end).toMillis();
this.bytes.getAndAdd(len);
final long millis = Duration.between(start, end).toMillis();
this.time.getAndAdd(millis);
final Level level = this.logger.getLevel();
if (!level.equals(Level.INFO)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/scalar/ItemAt.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public ItemAt(
) {
this.saved = new Sticky<>(
() -> {
final T ret;
if (position < 0) {
throw new IOException(
new FormattedText(
Expand All @@ -112,6 +111,7 @@ public ItemAt(
for (cur = 0; cur < position && src.hasNext(); ++cur) {
src.next();
}
final T ret;
if (cur == position && src.hasNext()) {
ret = src.next();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Rotated.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public Rotated(final Text text, final int shift) {
origin -> {
final int length = origin.length();
if (length != 0 && shift != 0 && shift % length != 0) {
final StringBuilder builder = new StringBuilder(length);
int offset = -(shift % length);
if (offset < 0) {
offset = origin.length() + offset;
}
final StringBuilder builder = new StringBuilder(length);
origin = builder.append(
origin.substring(offset)
).append(
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/func/TimedFuncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void functionGetsInterrupted() throws Exception {
@Test
@SuppressWarnings("PMD.AvoidCatchingGenericException")
public void futureTaskIsCancelled() {
final long period = 50L;
final long time = 2000L;
final Future<Boolean> future = Executors.newSingleThreadExecutor()
.submit(
Expand All @@ -65,6 +64,7 @@ public void futureTaskIsCancelled() {
}
);
try {
final long period = 50L;
new Timed<Boolean, Boolean>(
period,
input -> future
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/io/WriterAsOutputStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public void writesLargeContentToFile() throws IOException {
@Test
public void writesToFileAndRemovesIt() throws Exception {
final Path temp = this.folder.newFile().toPath();
final String content = "Hello, товарищ! How are you?";
try (OutputStreamWriter writer = new OutputStreamWriter(
Files.newOutputStream(temp.toAbsolutePath()),
StandardCharsets.UTF_8
)) {
final String content = "Hello, товарищ! How are you?";
new LengthOf(
new TeeInput(
new InputOf(content),
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/cactoos/scalar/BinaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public final class BinaryTest {

@Test
public void conditionTrue() {
final int expected = 1;
final AtomicInteger counter = new AtomicInteger(0);
final Binary binary = new Binary(
new True(),
Expand All @@ -51,6 +50,7 @@ public void conditionTrue() {
binary,
new HasValue<>(true)
).affirm();
final int expected = 1;
new Assertion<>(
"Binary has to invoke increment method",
counter.get(),
Expand All @@ -60,7 +60,6 @@ public void conditionTrue() {

@Test
public void conditionFalse() {
final int expected = 0;
final AtomicInteger counter = new AtomicInteger(0);
final Binary binary = new Binary(
new False(),
Expand All @@ -71,6 +70,7 @@ public void conditionFalse() {
binary,
new HasValue<>(false)
).affirm();
final int expected = 0;
new Assertion<>(
"Binary must not to invoke increment method",
counter.get(),
Expand Down

0 comments on commit 7ef2c0f

Please sign in to comment.