Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.nio.charset.UnmappableCharacterException: Input length = 1 #134

Closed
RadoBuransky opened this issue Sep 24, 2015 · 19 comments
Closed

java.nio.charset.UnmappableCharacterException: Input length = 1 #134

RadoBuransky opened this issue Sep 24, 2015 · 19 comments

Comments

@RadoBuransky
Copy link
Contributor

I have some nice Slovak characters in source code. For example:

class Class2 {
  def msg_test = println("test code ŠTEFÁNIK")
}

But then if I run Scoverage it crashes with following:

Input length = 1
java.nio.charset.UnmappableCharacterException: Input length = 1
    at java.nio.charset.CoderResult.throwException(CoderResult.java:282)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.read1(BufferedReader.java:210)
    at java.io.BufferedReader.read(BufferedReader.java:286)
    at java.io.Reader.read(Reader.java:140)
    at scala.io.BufferedSource.mkString(BufferedSource.scala:96)
    at scoverage.report.CodeGrid.source(CodeGrid.scala:63)
    at scoverage.report.CodeGrid.<init>(CodeGrid.scala:17)
    at scoverage.report.ScoverageHtmlWriter.filePage(ScoverageHtmlWriter.scala:78)

It is obviously related to encoding. I am able to reproduce it by explicitly setting wrong encoding in CodeGrid.scala line 63:

  private def source(mfile: MeasuredFile): String = Source.fromFile(mfile.source, "windows-1252").mkString

Current implementation uses an arbitrary default encoding which is probably not ideal. It can be different for every one of us. I would propose to hardcode UTF-8. If you like this idea, I will send a pull request soon.

filipmatusak pushed a commit to filipmatusak/scalac-scoverage-plugin that referenced this issue Sep 24, 2015
@mismare
Copy link

mismare commented Nov 12, 2015

Hi guys,

Do you have an estimate as to when the fix is going to be released?

Thanks,
Ema

@RadoBuransky
Copy link
Contributor Author

@sksamuel Sam?

@sksamuel
Copy link
Member

I'll do a release tonight.

@mismare
Copy link

mismare commented Nov 12, 2015

Great, thanks!

@gslowikowski
Copy link
Member

Is this issue fixed? Where/when?

@RadoBuransky
Copy link
Contributor Author

@gslowikowski #135

@gslowikowski
Copy link
Member

I missed this PR. It's late, but I must say, I don't like this solution. I would like to have possibility to parametrize source encoding. This is natural in all Maven plugins I'm using. I don't want to add warning to Scoverage Maven plugin, that UTF-8 is the only acceptable encoding since next version. It can be default, but add the possibility to change it.

@mismare
Copy link

mismare commented Nov 13, 2015

Hi guys,

Any updates on this ?

Thanks,
Ema

@gslowikowski
Copy link
Member

Here you have alternative approach - source encoding parametrized

@gslowikowski
Copy link
Member

Very simple SBT plugin implementation - https://github.com/gslowikowski/sbt-scoverage/tree/source-encoding.
In SBT encoding can and should be found in scalacOptions if not specified in coverageSourceEncoding setting key. Someone with better SBT knowledge can implement this logic.

@gslowikowski
Copy link
Member

scoverage/sbt-scoverage#86 is related to this issue and will be fixed, if my proposed solutions will be accepted.

@gslowikowski
Copy link
Member

SBT plugin proposed implementation (https://github.com/gslowikowski/sbt-scoverage/commits/source-encoding) improved - default encoding value pulled from scalacOptions in (Compile). It's complete now.

@gslowikowski
Copy link
Member

Nobody's interested in this functionality anymore?

@gslowikowski
Copy link
Member

I've created new PR based on current code.

@gslowikowski
Copy link
Member

PR for SBT ready - scoverage/sbt-scoverage#155

@gslowikowski
Copy link
Member

Maven version is still valid.

@gslowikowski
Copy link
Member

If nobody objects, I will apply all PRs.

sksamuel added a commit that referenced this issue Jan 31, 2016
Source encoding parametrization - fix for issue #134
@gslowikowski
Copy link
Member

PR merged, 1.2.0-SNAPSHOT version published.
Maven implementation done (see scoverage/scoverage-maven-plugin#29)
SBT PR waiting for merge. @sksamuel ?
@maiflai, will you implement it in Gradle?

gslowikowski added a commit to scoverage/sbt-scoverage that referenced this issue Feb 8, 2016
@gslowikowski
Copy link
Member

sbt-scoverage PR merged. 1.3.6-SNAPSHOT snapshot published to Sonatype OSS snapshots repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants