Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code and exception declarations #5461

Merged
merged 8 commits into from
Mar 16, 2018
Merged

Conversation

leventov
Copy link
Member

@leventov leventov commented Mar 2, 2018

Removes a lot, but still not all unused code in the project.

Labelled Incompatible because removes some exceptions from throws clauses of some methods in @ExtensionPoint interfaces.

@gianm
Copy link
Contributor

gianm commented Mar 2, 2018

Thanks @leventov this is great housekeeping! I was surprised to learn that DataSegmentPuller isn't used anywhere 🌈⭐️

I don't see a reason to remove "redundant throws" in extension point interfaces. For example, this patch removes "throws Exception" in FirehoseV2's start method. Why? What's wrong with letting extensions throw exceptions there if they want to?

I think this patch could be done in a non-incompatible way and it might even be better off like that.

@gianm
Copy link
Contributor

gianm commented Mar 2, 2018

Okay, nevermind, it must be incompatible because of the removal of DataSegmentPuller. But I still am skeptical of the removal of throws clauses from extension interfaces.

@leventov
Copy link
Member Author

leventov commented Mar 9, 2018

@gianm this PR is going to be incompatible even if I return Exceptions to throws clauses at some places, because it removes DataSegmentPuller.

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

I didn't read the entire diff, but I skimmed around and noticed a couple issues. Please double-check to see if there are any similar issues to the @JsonProperty one in RequestLogLine.

@JsonProperty("timestamp")
public DateTime getCreatedTime()
{
return request.getTimestamp();
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should stay, since it's part of the serialized JSON (same goes for anything @JsonProperty).

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted the method. There are no other occurrences when @JsonProperty is removed in this PR

@@ -161,7 +161,7 @@ public ExecuteResult prepareAndExecute(
final String sql,
final long maxRowCount,
final PrepareCallback callback
) throws NoSuchStatementException
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of deleting the throws NoSuchStatementException, probably getDruidStatement should be changed to throw NoSuchStatementException instead of IllegalStateException when the statement is not found.

Copy link
Member Author

Choose a reason for hiding this comment

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

Made this change. Also note that authConfig is unused in DruidMeta, that might be a sign of some problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I guess don't worry about authConfig in this PR. I'll double check what's going on there separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

It turns out they weren't necessary. #5483

@@ -1,3 +1,7 @@
<component name="DependencyValidationManager">
<scope name="UnusedInspectionsScope" pattern="src[druid-processing]:*..*" />
<scope name="UnusedInspectionsScope" pattern="src[java-util]:*..*" />
Copy link
Contributor

Choose a reason for hiding this comment

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

this will need to changes if we merge #5490 first

@@ -41,5 +39,5 @@
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface FirehoseFactoryV2<T extends InputRowParser>
{
FirehoseV2 connect(T parser, Object lastCommit) throws IOException, ParseException;
FirehoseV2 connect(T parser, Object lastCommit) throws ParseException;
Copy link
Contributor

Choose a reason for hiding this comment

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

am wondering why we are removing IOException, seems reasonable that such method will throw IOException?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because nobody actually throwing it

Copy link
Contributor

Choose a reason for hiding this comment

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

But it is legitimate kind of exception that maybe in the future or other external implementations will need it, FirehoseFactoryV2.java is an extension point, IMO we should keep it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted

@leventov
Copy link
Member Author

@gianm @b-slim do you have more comments here?

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

@leventov no further comments; I am good with this.

@b-slim
Copy link
Contributor

b-slim commented Mar 16, 2018

👍 after tests.

@leventov leventov merged commit 693e357 into apache:master Mar 16, 2018
@leventov
Copy link
Member Author

Thanks for reviews

@leventov leventov deleted the unused3 branch March 16, 2018 21:11
@drcrallen
Copy link
Contributor

I was using java-util/src/main/java/io/druid/java/util/http/client/response/ToStringResponseHandler.java in an extension :-/

@drcrallen
Copy link
Contributor

was also using some of the methods in Event

@drcrallen
Copy link
Contributor

drcrallen commented Jun 26, 2018

And MapUtils. getLong

@drcrallen
Copy link
Contributor

This PR will need a special callout in the release notes that a lot of java-util functions were removed.

@dclim dclim added this to the 0.13.0 milestone Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants