1

I have code that iterates over timestamps in a video, and adds the timestamp and the thumbnail of that timestamp to a list:

timeStamps.each { timeStampMs -> //for each carousel timestamp
     Optional<byte[]> thumbnail = this.persistenceService.getThumbnail(collectionName, mediaId, timeStampMs)
     if (thumbnail.isPresent()) {
         timeThumbnailList << new TimeThumbnailPair(timeStampMs: timeStampMs, thumbnail: thumbnail.get())
     } else {
         absentTimeStamps << timeStampMs //assign to thumbnails that needs to be decoded
     }
}

TimeThumbnailPair looks like this:

@Canonical
class TimeThumbnailPair {

    Long timeStampMs

    byte[] thumbnail
}

When I try to compile my code, I get the following error:

"Error:(83, 103) Groovyc: [Static type checking] - Cannot assign value of type byte[] to variable of type byte[]"

I'm completely lost as to why this error appears (and what it even means). Thanks in advance!

3
  • 1
    Do you have the CompileStatic annotation on this class (or method)? If so, does this work if its turned off? Also what version of Groovy are you using? Commented Apr 27, 2017 at 18:08
  • @cjstehno Thank you, this solved my issue. If you'd like to add this as an answer, I'll accept it as the answer to the question. Commented May 4, 2017 at 14:20
  • Glad it helped. Commented May 4, 2017 at 15:14

1 Answer 1

1

Add or remove a @CompileStatic on the class or method. Sometimes primitive arrays can be picky.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.