google / google/jimfs

Allow to write to PathURLConnection

Open
#161 2 comments 0 reactions 1 assignee Claimed by @cgdecker View on GitHub
P3 type=enhancement
Dominant language
Java
Stars
2.6k
Forks
296
Avg merge
9m
Merged PRs (30d)
7

Description

Hey,

we ran into some issues in our unit tests, where EMF is trying to write to some URL in the jimfs filesystem.

The stack is the following:
```java
PathURLConnection.getOutputStream() line: 130 => "protocol doesn't support output"
URIHandlerImpl.createOutputStream(URI, Map) line: 154
ExtensibleURIConverterImpl.createOutputStream(URI, Map) line: 349
PlatformResourceURIHandlerImpl.createOutputStream(URI, Map) line: 498
ExtensibleURIConverterImpl.createOutputStream(URI, Map) line: 349
ModelResourceImpl(ResourceImpl).save(Map) line: 1041
```
To make EMF aware of jimfs, we register the top-level URI of a jimfs path into the ecore 'platform resource map' (essentially a map from Eclipse IProject -> URI) in the test setup:

```java
EcorePlugin.getPlatformResourceMap().put("VdkWithVHub", URI.createURI(top.toUri().toString()));
```

It would be good, if the [PathURLConnection](https://github.com/google/jimfs/blob/master/jimfs/src/main/java/com/google/common/jimfs/PathURLConnection.java) could also implement the write protocol.

A trivial implementation fixed the issue for us: [pull request](https://github.com/google/jimfs/pull/160)

We would kindly ask to review the change and make suggestions if you see any violations of the protocol.

also see: #13 [Obtaining a URL from a jimfs path](https://github.com/google/jimfs/issues/13)

Thanks
Janik

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.