Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-478

Updating from 1.7.25 to 2.0.0-alpha1 breaks

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • None
    • None

    Description

      When I try to upgrade sl4j-api from 1.7.25 to version 1.8.X and 2.X. The following code breaks.

      public class TestSl4j extends AbstractTest4StdOut {
      
      	
      	@Test
      	public void demo() throws Exception{
              final Logger logger = LoggerFactory.getLogger(TestSl4j.class);
      
              // Log in Main Thread
              logger.info("Log in main!");
              assertEquals("[] {} - Log in main!", getLogAndClear());
      		
      	}
      }
      
      public abstract class AbstractTest4StdOut {
          @Rule
          public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
      
          protected static final long START_TIME_STAMP = System.currentTimeMillis();
      
          protected String getLogAndClear() {
              System.out.flush();
      
              final String out = systemOutRule.getLog();
              systemOutRule.clearLog();
      
              final int idx = out.indexOf('\n');
              return out.substring(idx + 1, out.length() - 1); // trim first line and last '\n'
          }
      }
      

      The code should pass, but it throws an error:

      [ERROR] demo(TestSl4j)  Time elapsed: 0.018 s  <<< ERROR!
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at demo(TestSl4j.java:19)
      

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            xia0c Lingchao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: