Skip to content

Commit

Permalink
only accept numeric Block values
Browse files Browse the repository at this point in the history
  • Loading branch information
klk32003 committed Jun 28, 2020
1 parent a5b5aee commit 9c4833d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions java/src/jmri/jmrit/vsdecoder/VSDecoderManager.java
Expand Up @@ -678,14 +678,14 @@ public void blockPropertyChange(PropertyChangeEvent event) {
if (event.getNewValue() instanceof String) {
repVal = event.getNewValue().toString();
// Is the new event value a valid VSDecoder address? If OK, set the sound position
if (! repVal.trim().isEmpty()) {
int address = Integer.parseInt(repVal);
if (decoderInBlock.containsKey(address)) {
if (org.apache.commons.lang3.StringUtils.isNumeric(repVal)) {
int locoAddress = Integer.parseInt(repVal);
if (decoderInBlock.containsKey(locoAddress)) {
if (blk.getPhysicalLocation() == null) {
log.warn("Block {} has no physical location!", blk.getSystemName());
} else {
log.debug("Block value: {}, physical location: {}", event.getNewValue(), blk.getPhysicalLocation());
decoderInBlock.get(address).setPosition(blk.getPhysicalLocation());
decoderInBlock.get(locoAddress).setPosition(blk.getPhysicalLocation());
}
} else {
log.warn("Block value \"{}\" is not a valid VSDecoder address", event.getNewValue());
Expand Down

0 comments on commit 9c4833d

Please sign in to comment.