# Custom task with nested Enum causes UncheckedIOException (Could not read entry from cache taskArtifacts.bin)

**URL:** <https://discuss.gradle.org/t/custom-task-with-nested-enum-causes-uncheckedioexception-could-not-read-entry-from-cache-taskartifacts-bin/1240>\
**Category:** Old Forum Archive\
**Created:** [September 4, 2014, 7:12am UTC](https://discuss.gradle.org/t/custom-task-with-nested-enum-causes-uncheckedioexception-could-not-read-entry-from-cache-taskartifacts-bin/1240 "2014-09-04T07:12:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abegg\_ch](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@abegg\_ch](https://discuss.gradle.org/u/abegg_ch)\
**Post date:** [September 4, 2014, 7:12am UTC](https://discuss.gradle.org/t/custom-task-with-nested-enum-causes-uncheckedioexception-could-not-read-entry-from-cache-taskartifacts-bin/1240/1 "2014-09-04T07:12:00Z")

</div>

I have implemented the following custom task which uses a nested enum: [https://gist.github.com/abeggchr/b338d827312a67526cac](https://gist.github.com/abeggchr/b338d827312a67526cac)

When executing an instance of this task (for the second time), the following exception is thrown:

```gradle
org.gradle.api.UncheckedIOException: Could not read entry ':problem' from cache taskArtifacts.bin (/home/sam/Downloads/UncheckedIOException/.gradle/2.0/taskArtifacts/taskArtifacts.bin).
 at org.gradle.cache.internal.btree.BTreePersistentIndexedCache.get(BTreePersistentIndexedCache.java:129)
 at org.gradle.cache.internal.DefaultMultiProcessSafePersistentIndexedCache$1.create(DefaultMultiProcessSafePersistentIndexedCache.java:37)
...
Caused by: java.lang.ClassNotFoundException: com.mine.tasks.TaskWithEnum$Language
 at org.gradle.internal.io.ClassLoaderObjectInputStream.resolveClass(ClassLoaderObjectInputStream.java:40)
 at org.gradle.messaging.serialize.DefaultSerializer.read(DefaultSerializer.java:45)
 at org.gradle.messaging.serialize.MapSerializer.read(MapSerializer.java:37)
 at org.gradle.api.internal.changedetection.state.InputPropertiesSerializer.read(InputPropertiesSerializer.java:35)
...

```

Deleting the “.gradle” directory only helps for the first build after the deletion. The second build will fail again.

Refactoring the Enum to a separate file (i.e. com.mine.tasks.Language) does not help either: The same UncheckedIOException caused by ClassNotFoundException is thrown.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [September 4, 2014, 7:52am UTC](https://discuss.gradle.org/t/custom-task-with-nested-enum-causes-uncheckedioexception-could-not-read-entry-from-cache-taskartifacts-bin/1240/2 "2014-09-04T07:52:00Z")

</div>

Hi,&nbsp;  
  
This is&nbsp;GRADLE-2771.  
  
What you can do is store the input as a string. You can remove the @Input from the enum and add another package scope method (not sure if private works) with @Input that returns the toString() of the enum.
