Skip to content

Commit

Permalink
explicit ClassLoader parameter for ServiceLoader
Browse files Browse the repository at this point in the history
The explicit classloader is necessary for Android to be able to find and
load the declared NetworkModuleFactories

Signed-off-by: Maik Scheibler <eclipse@scheibler-family.de>
  • Loading branch information
Maik Scheibler committed Nov 20, 2017
1 parent 16e394e commit 314246c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.paho.client.mqttv3.internal;

Expand Down Expand Up @@ -34,7 +34,7 @@ public class NetworkModuleService {
private static final Logger LOG = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT,
NetworkModuleService.class.getSimpleName());
private static final ServiceLoader<NetworkModuleFactory> FACTORY_SERVICE_LOADER = ServiceLoader.load(
NetworkModuleFactory.class);
NetworkModuleFactory.class, NetworkModuleService.class.getClassLoader());

This comment has been minimized.

Copy link
@gaborauth

gaborauth Mar 13, 2019

Maybe related to the issue #630?

This comment has been minimized.

Copy link
@kami4ka

kami4ka Apr 12, 2019

@icraggs looks like it can be a solution for resolving Android crash for 1.2.1


/** Pattern to match URI authority parts: {@code authority = [userinfo"@"]host[":"port]} */
private static final Pattern AUTHORITY_PATTERN = Pattern.compile("((.+)@)?([^:]*)(:(\\d+))?");
Expand Down Expand Up @@ -126,7 +126,7 @@ static void applyRFC3986AuthorityPatch(URI toPatch) {
return;
}
Matcher matcher = AUTHORITY_PATTERN.matcher(toPatch.getAuthority());
if (matcher.matches()) {
if (matcher.find()) {
setURIField(toPatch, "userInfo", matcher.group(AUTH_GROUP_USERINFO));
setURIField(toPatch, "host", matcher.group(AUTH_GROUP_HOST));
String portString = matcher.group(AUTH_GROUP_PORT);
Expand Down

0 comments on commit 314246c

Please sign in to comment.