Skip to content

Commit

Permalink
Fixed another NPE on newly added zone player
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Kreuzer <kai@openhab.org> (github: @kaikreuzer)
  • Loading branch information
kaikreuzer committed Nov 14, 2014
1 parent a0a0eca commit f333055
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,10 @@ public void initialize() {
if (configuration.udn != null) {
onSubscription();
onUpdate();
super.initialize();
} else {
logger.warn("Cannot initalize the zoneplayer. UDN not set.");
}

if (getThing().getStatus() == ThingStatus.OFFLINE) {
logger.debug("Setting status for thing '{}' to ONLINE", getThing()
.getUID());
getThing().setStatus(ThingStatus.ONLINE);
}
}

@Override
Expand Down Expand Up @@ -1251,28 +1246,29 @@ public void playLineIn(Command command) {

protected ZonePlayerHandler getHandlerByName(String remotePlayerName) {

Thing thing = thingRegistry.getByUID(new ThingUID(
ZONEPLAYER_THING_TYPE_UID, remotePlayerName));

if (thing == null) {
Collection<Thing> allThings = thingRegistry.getAll();
for (Thing aThing : allThings) {
if (aThing.getThingTypeUID().equals(
this.getThing().getThingTypeUID())) {
if (aThing.getConfiguration().get(UDN)
.equals(remotePlayerName)) {
thing = aThing;
break;
if(thingRegistry!=null) {
Thing thing = thingRegistry.getByUID(new ThingUID(
ZONEPLAYER_THING_TYPE_UID, remotePlayerName));

if (thing == null) {
Collection<Thing> allThings = thingRegistry.getAll();
for (Thing aThing : allThings) {
if (aThing.getThingTypeUID().equals(
this.getThing().getThingTypeUID())) {
if (aThing.getConfiguration().get(UDN)
.equals(remotePlayerName)) {
thing = aThing;
break;
}
}
}
}
}

if(thing != null) {
return (ZonePlayerHandler) thing.getHandler();
} else {
return null;
if(thing != null) {
return (ZonePlayerHandler) thing.getHandler();
}
}
return null;

}

Expand Down

0 comments on commit f333055

Please sign in to comment.