SmartSprites

SmartSprites 0.2.7 throws StringIndexOutOfBoundsExeception when run in Windows system

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.2.7
  • Fix Version/s: 0.2.8
  • Component/s: None
  • Labels:
    None

Description

When SmartSprites run in Windows system, it throws this exception:

---------------------------------------------------
INFO: Initializing Spring FrameworkServlet 'spring'
Jan 24, 2011 9:49:25 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet / threw load() exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1937)
at org.carrot2.labs.smartsprites.SpriteBuilder.createProcessedCss(SpriteBuilder.java:327)
at org.carrot2.labs.smartsprites.SpriteBuilder.rewriteCssFiles(SpriteBuilder.java:260)
at org.carrot2.labs.smartsprites.SpriteBuilder.buildSprites(SpriteBuilder.java:211)
...
---------------------------------------------------

I think the problem is on this part of the code:

"originalCssFile.lastIndexOf(File.separatorChar)"

The css file is using the forward slash "/", but when the SmartSprites runs in Windows, it will try to look for "\", which is not found!
/** sprite: iconSprite; sprite-image: url('../../../img/bg_sprite_icons.png'); sprite-layout: vertical; */

Activity

Hide
Stanisław Osiński added a comment -

Thanks for the report! The bug was cause by the lack of clear contract on the SpriteBuilder.buildSprites(Collection<String> files) method. Previously, the method would work only with platform-specific path separator, now it also accepts '/' as the separator, even if the platform-specific character is different.

When you have a sec, please check if version 0.2.8-dev fixes your issue. If you don't discover any other problems, I'll release 0.2.8 with this fix.

Show
Stanisław Osiński added a comment - Thanks for the report! The bug was cause by the lack of clear contract on the SpriteBuilder.buildSprites(Collection<String> files) method. Previously, the method would work only with platform-specific path separator, now it also accepts '/' as the separator, even if the platform-specific character is different. When you have a sec, please check if version 0.2.8-dev fixes your issue. If you don't discover any other problems, I'll release 0.2.8 with this fix.
Hide
David Cai added a comment -

It fixed the issue! I tested it under Windows and Mac, ok so far!

Show
David Cai added a comment - It fixed the issue! I tested it under Windows and Mac, ok so far!
Hide
David Cai added a comment -

When are you going to release version 0.2.8?

Show
David Cai added a comment - When are you going to release version 0.2.8?
Hide
Stanisław Osiński added a comment -

Hi David,

I'm hoping to make the release this week. Additionally, I'll be setting up infrastructure for uploading the binaries to Maven central, so you should be able to grab them directly from the primary source.

S.

Show
Stanisław Osiński added a comment - Hi David, I'm hoping to make the release this week. Additionally, I'll be setting up infrastructure for uploading the binaries to Maven central, so you should be able to grab them directly from the primary source. S.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
0h
Original Estimate - 0h
Remaining:
0h
Remaining Estimate - 0h
Logged:
1h
Time Spent - 1h