Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/tools/StreamsResetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public int run(final String[] args,
e.printStackTrace(System.err);
} finally {
if (kafkaAdminClient != null) {
kafkaAdminClient.close(60, TimeUnit.SECONDS);
kafkaAdminClient.close(java.time.Duration.ofSeconds(60));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot import java.time.Duration because we already import javax.xml.datatype.Duration.

I was wondering if we could get rid of javax.xml.datatype.Duration though and replace it with java.time.Duration that was not available in Java7 when we added javax.xml.datatype.Duration.

Thoughts? \cc @jeqo who extended the reset tool via #3831

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place we need this duration is

duration.negate().addTo(now);

java.time.Duration has negated but its addTo is taking a Temporal, and all its extends like LocalTime etc do not have the right API of getTime. So I think we just keep it like this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove the javax.xml.datatype.Duration usage since it's not part of the Java base module.

@mjsax mjsax Jan 22, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was locking into the corresponding KIPs

Both say:

--by-duration  PnDTnHnMnS

Duration must be specified in ISO8601 format.

Looking into JavaDocs of java.time.Duration#parse() it says:

     * Obtains a {@code Duration} from a text string such as {@code PnDTnHnMn.nS}.
     * <p>
     * This will parse a textual representation of a duration, including the
     * string produced by {@code toString()}. The formats accepted are based
     * on the ISO-8601 duration format {@code PnDTnHnMn.nS} with days
     * considered to be exactly 24 hours.

Thus, it seems save to replace

final javax.xml.datatype.Duration durationParsed = DatatypeFactory.newInstance().newDuration(duration);

with

final java.time.Duration durationParsed = java.time.Duration.parse(duration);

Btw: we should do the same for kafka.admin.ConsumerGroupCommand (I can add this change to this PR).

Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjsax LGTM

Both kafka/tools/StreamsResetter.java and kafka/admin/ConsumerGroupCommand.scala should be migrated to remove usage of javax.xml.datatype.*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjsax , I agree, it seems safe and desirable to swap them out.

}
}

Expand Down