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

[EAGLE-1012] Some language level problems in `eagle-core` module #925

Closed
wants to merge 5 commits into from

Conversation

@asdf2014
Copy link
Member

commented Apr 19, 2017

Some language level problems

  • Spell
  • Duplicated
  • Lambda
  • Collection
  • String
  • instanceof
  • Complex Method
  • Exception
  • AutoClose
  • Synchronized

Details see attachment files.

@asdf2014 asdf2014 changed the title [EAGLE-1012] Some language level problems [WIP][EAGLE-1012] Some language level problems Apr 19, 2017

@asdf2014 asdf2014 changed the title [WIP][EAGLE-1012] Some language level problems [EAGLE-1012] Some language level problems in `eagle-core` module Apr 19, 2017

@asdf2014

This comment has been minimized.

Copy link
Member Author

commented May 2, 2017

If these improvements are necessary, we should step by step merge to avoid too much code conflict. So, creating multiple sub PRs for EAGLE-1012 will be more suitable for this situation. What do you think? @jhsenjaliya @qingwen220

@@ -43,8 +43,6 @@ public static AttributeResolvable getAttributeResolver(String fieldResolverName,
fieldResolvableCache.put(fieldResolverName, instance);
} catch (ClassNotFoundException e) {
throw new AttributeResolveException("Attribute Resolver in type of " + fieldResolverName + " is not found", e);
} catch (InstantiationException | IllegalAccessException e) {

This comment has been minimized.

Copy link
@jhsenjaliya

jhsenjaliya May 2, 2017

Contributor

instead of removing this, it can be used to describe the error, IDE is suggesting to collapse the catch block may be because it has identical error msg (throw new AttributeResolveException(e)).

This comment has been minimized.

Copy link
@asdf2014

asdf2014 May 2, 2017

Author Member

I see. I will roll it back.

for (AlertStreamEvent e : eventList) {
alertEvents.add(AlertPublishEvent.createAlertPublishEvent(e));
}
List<AlertPublishEvent> alertEvents = eventList.stream().map(

This comment has been minimized.

Copy link
@jhsenjaliya

jhsenjaliya May 2, 2017

Contributor

i feel its fancy to use newer java features, but old syntax is more readable, may be its just a coding preference

This comment has been minimized.

Copy link
@asdf2014

asdf2014 May 2, 2017

Author Member

I think it will bring better maintainability and performance.

This comment has been minimized.

Copy link
@asdf2014

asdf2014 May 2, 2017

Author Member

Maybe you are right, i will roll it back. 👍

This comment has been minimized.

Copy link
@asdf2014

asdf2014 May 2, 2017

Author Member

I have created a non-professional benchmark test. After adding -Xmx2G -Xms2G -Xmn1G -XX:+AlwaysPreTouch params for reducing the impact from jvm resources, then found the performance gap is not very large, and the performance of lambda stream is better than simple for loop after the data becomes larger.

@@ -199,7 +194,7 @@ private void closePlugins(List<AlertPublishPlugin> toBeClosed) {
try {
p.close();
} catch (Exception e) {
LOG.error(String.format("Error when close publish plugin {}!", p.getClass().getCanonicalName()), e);
LOG.error(String.format("Error when close publish plugin %s!", p.getClass().getCanonicalName()), e);

This comment has been minimized.

Copy link
@jhsenjaliya

jhsenjaliya May 2, 2017

Contributor

people are using this interchangeably

This comment has been minimized.

Copy link
@asdf2014

asdf2014 May 2, 2017

Author Member

String.format should use %s rather than {}

@Test
public void testFormat() {
    assertEquals("a{}c", String.format("a{}c", "b"));
    assertEquals("abc", String.format("a%sc", "b"));
}
@jhsenjaliya

This comment has been minimized.

Copy link
Contributor

commented May 2, 2017

@asdf2014 , i havent gone through all the changes yet, but looks like these are what some particular IDE would recommend, some are real improvements as well. lets check this out after 0.5, Thanks for the efforts !

@asdf2014

This comment has been minimized.

Copy link
Member Author

commented May 2, 2017

@jhsenjaliya Okay, i see. Thx for your code review.

@jhsenjaliya

This comment has been minimized.

Copy link
Contributor

commented May 2, 2017

@asdf2014 Thanks again, lets work on this after 0.5

@asdf2014

This comment has been minimized.

Copy link
Member Author

commented May 3, 2017

@jhsenjaliya You are welcome. Sorry, i just note it. Let’s finish this after v0.5.0 together.

@asdf2014 asdf2014 closed this Nov 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.