-
Notifications
You must be signed in to change notification settings - Fork 6
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
Plugin classes refactor #3
base: master
Are you sure you want to change the base?
Conversation
Add some Todos.
interrupt thread for InterruptedException
Few notes: In 909858d:
The IDE indicates that In 646ead5:
The IDE indicates that it's an "unchecked assignment: Reason: 'sub' has raw type, so result of getCurrentValues is erased". |
@Bombe is this good to go now? |
1 similar comment
@Bombe is this good to go now? |
Sure, but |
And for this one:
Yes, We could check whether a newer version of cling (2.1.2 is available, we’re using 2.1.0) has type parameters in its method declarations; other than that there’s little we can do. Cast it, ignore it, either would be fine with me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven’t delved into the UPnP protocol at all, all the synchronous network communication seems really weird to me but I’m assuming it works. 🙂
Service connectionService; | ||
if ((connectionService = discoverConnectionService(device)) == null) return; | ||
Service connectionService = discoverConnectionService(device); | ||
if (commonService == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already mentioned in the other comment, this needs to be connectionService == null
.
Service connectionService; | ||
if ((connectionService = discoverConnectionService(device)) == null) return; | ||
Service connectionService = discoverConnectionService(device); | ||
if (commonService == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dito.
}); | ||
} | ||
|
||
private UpnpService upnpService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be final
.
}); | ||
} | ||
|
||
private ServiceManager serviceManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Member variables initialized in the constructor should be final
.
|
||
serviceManager.waitForBooting(); | ||
|
||
synchronized (this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which of the members in this synchronized
are actually protected by it? Every single one of them is also used without a synchronized
block, so it’s either unnecessary or broken. :)
public Collection<DetectedIP> getExternalIPs() { | ||
waitForBooting(); | ||
|
||
if (connectionServices.size() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use connectionService.isEmpty()
, it’s way more descriptive.
*/ | ||
private void realGetExternalIPs() { | ||
|
||
if (connectionServices.size() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary. connectionService
is already checked for being empty before this method is called, and it’s called from nowhere else.
|
||
waitForBooting(); | ||
|
||
if (connectionServices.size() < 0 && commonServices.size() < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn’t make any sense. Collections can never have negative sizes.
return new IGDRates(upRatesSum, downRatesSum); | ||
} | ||
|
||
// We get nothing from GetLinkLayerMaxBitRates. Try GetCommonLinkProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost a duplicate of the first half of this method. It should be possible to extract the logic so it’s in a single place.
|
||
// We get nothing from GetLinkLayerMaxBitRates. Try GetCommonLinkProperties | ||
|
||
final List<Integer> upRates2 = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clear()
the other lists, declaring a second set of them is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And this might just go away if the common logic can be extracted, anyway. 🙂)
Picking up from branch #2 with original attribution. I'll be working on the comments left at https://github.com/freenet/plugin-UPnP2/pull/2/files: