javapns-jdk16 icon indicating copy to clipboard operation
javapns-jdk16 copied to clipboard

java.lang.StringIndexOutOfBoundsException: String index out of range: 64

Open zjor opened this issue 8 years ago • 2 comments

This harmful implementation gives OOB exception on short token like simulator generated by iOS IDE ` public String toString() { StringBuilder msg = new StringBuilder(); msg.append("[" + this.identifier + "]"); msg.append(this.transmissionCompleted?" transmitted " + this.payload + " on " + this.getLatestTransmissionAttempt():" not transmitted"); msg.append(" to token " + this.device.getToken().substring(0, 5) + ".." + this.device.getToken().substring(59, 64)); if(this.response != null) { msg.append(" " + this.response.getMessage()); }

        if(this.exception != null) {
            msg.append("  " + this.exception);
        }

        return msg.toString();
    }

`

zjor avatar Apr 06 '16 15:04 zjor

Sorry, but could not understand your issue. My understanding is that APNS does not provide a token to the iOS simulator, that is why you can only test push notifications using a real device. Please can you provide more info?

fernandospr avatar Apr 06 '16 22:04 fernandospr

My backend received simulator as a token value and the code broke in a place I would never expect. Even if token is not correct it's not the reason why toString method should fail because naturally people use it for logging outside try-catch structure and it may brake a lot...

zjor avatar Apr 07 '16 05:04 zjor