Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-271

Overriden encoding taken from InputStreamReader in ReaderResource constructor

XMLWordPrintable

    • Hide

      Resource resource = new ReaderResource(new InputStreamReader(new FileInputStream(RULE_FILENAME), "UTF-8"));
      ((ReaderResource)resource).getEncoding() <==== This is null

      Show
      Resource resource = new ReaderResource(new InputStreamReader(new FileInputStream(RULE_FILENAME), "UTF-8")); ((ReaderResource)resource).getEncoding() <==== This is null
    • Workaround Exists
    • Hide

      Developer can specify encoding manually.

      Show
      Developer can specify encoding manually.
    • Low

      If encoding of resource is passes as null and reader is InputStreamReader encoding taken from reader is overriden to null.
      "this.encoding = encoding;" should be in else block in my opinion.

      public ReaderResource(Reader reader, String encoding, ResourceType type ) {
      if ( reader == null )

      { throw new IllegalArgumentException( "reader cannot be null" ); }

      if ( encoding == null && reader instanceof InputStreamReader )

      { this.encoding = ((InputStreamReader)reader).getEncoding(); <== encoding assigned here }

      this.reader = reader;

      this.encoding = encoding; <== encoding assigned to null

      setResourceType( type );

      this.timestamp = System.currentTimeMillis();
      this.lastRead = this.timestamp;
      }

              psiroky_jira Petr Široký (Inactive)
              rzydu Jacek Walkowiak (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: