alecgorge/jsonapi — Issue #102: StringIndexOutOfBoundsException
Author: Evenprime
Created: 2011-12-09 20:19:05+00:00
State: open

Hi

A user of my Minecraft plugin sent me a stacktrace that contains an error that is relevant to your program. I'll paste the relevant part of the stacktrace:

```Java
2011-12-09 20:30:43 [SEVERE] NC: Plastickwood failed fight.selfhit: tried to attack himself. Total violation level so far 1.
2011-12-09 20:30:43 [SEVERE] Could not pass event ENTITY_DAMAGE to NoCheat
java.lang.StringIndexOutOfBoundsException: String index out of range: 200
at java.lang.String.substring(Unknown Source)
at com.alecgorge.minecraft.jsonapi.adminium.PushNotificationDaemon$ConsoleHandler.publish(PushNotificationDaemon.java:95)
at java.util.logging.Logger.log(Unknown Source)
at java.util.logging.Logger.doLog(Unknown Source)
at java.util.logging.Logger.log(Unknown Source)
at cc.co.evenprime.bukkit.nocheat.log.LogManager.logToConsole(LogManager.java:56)
at cc.co.evenprime.bukkit.nocheat.log.LogManager.log(LogManager.java:41)
at cc.co.evenprime.bukkit.nocheat.NoCheat.log(NoCheat.java:184)
...
```
"NC: Plastickwood failed fight.selfhit: tried to attack himself. Total violation level so far 1." is the message that gets logged by my plugin with SEVERE loglevel.

https://github.com/alecgorge/jsonapi/blob/master/src/com/alecgorge/minecraft/jsonapi/adminium/PushNotificationDaemon.java#L95 trims SEVERE logs down to 200 characters, but will fail if the message is already shorter than that (it is only ~100 characters in this case) with the above error.

Thank you in advance for fixing this.