Changeset f0b9894e for core/java


Ignore:
Timestamp:
Mar 1, 2018 4:26:31 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
67e07d2
Parents:
74dc427
Message:

Util: Warn on dubious split() regex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/DataHelper.java

    r74dc427 rf0b9894e  
    19521952     *
    19531953     *  @param s non-null
    1954      *  @param regex non-null
     1954     *  @param regex non-null, don't forget to enclose multiple choices with []
    19551955     *  @throws java.util.regex.PatternSyntaxException unchecked
    19561956     *  @since 0.9.24
     
    19671967     *
    19681968     *  @param s non-null
    1969      *  @param regex non-null
     1969     *  @param regex non-null, don't forget to enclose multiple choices with []
    19701970     *  @param limit result threshold
    19711971     *  @throws java.util.regex.PatternSyntaxException unchecked
     
    19751975        Pattern p = patterns.get(regex);
    19761976        if (p == null) {
     1977            // catches easy mistake, and also swapping the args by mistake
     1978            if (regex.length() > 1 && !regex.startsWith("[") && !regex.equals("\r\n")) {
     1979                //(new Exception("Warning: Split on regex: \"" + regex + "\" should probably be enclosed with []")).printStackTrace();
     1980                System.out.println("Warning: Split on regex: \"" + regex + "\" should probably be enclosed with []");
     1981            }
    19771982            p = Pattern.compile(regex);
    19781983            patterns.putIfAbsent(regex, p);
Note: See TracChangeset for help on using the changeset viewer.