-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
14.0.1
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
# Operating system
```
Linux 5.5.0-2-amd64 #1 SMP Debian 5.5.17-1 (2020-04-15) x86_64 GNU/Linux
```
# Java Runtime Information
```
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7-Debian-1)
OpenJDK 64-Bit Server VM (build 14.0.1+7-Debian-1, mixed mode, sharing)
```
A DESCRIPTION OF THE PROBLEM :
# Request for Enhancement
This request may be considered as related toJDK-8048203.
Provide a way to implement a file-based cookie store, i.e. a way to serialize and deserialize the instances of the `java.net.HttpCookie` class.
The `java.net.HttpCookie` class is proposed to be updated, because of the current design:
1. The `java.net.CookieStore` interface uses (depends on) the `java.net.HttpCookie` class.
2. The `java.net.HttpCookie` class is `final`.
# Rationale
The file-based cookie store represents a quite commonly used use case.
Currently, there is no straightforward (simple and easy) way to implement such a store, because there is no way to serialize and deserialize the instances of the `java.net.HttpCookie` class.
# Observations on current `java.net.HttpCookie` class
Please, consider the below observations on the **current** design and implementation of the `java.net.HttpCookie` class.
## 1. The class is not serializable
At least, the class does not implement the `java.io.Serializable` interface.
## 2. The class does not provide an external string representation
This is to serialize and deserialize without losing the information.
Counterexample. Using the methods, `toString()` and `parse(java.lang.String)`, causes the information loss.
## 3. The class completely hides the data as its state
Currently, there is no way to «deconstruct» and «construct» an instance of the class again using the cookie-related data.
For example, the `getCreationTime()` method is package-private and there is no constructor that accepts the creation time value.
Best regards,
XX.
# Operating system
```
Linux 5.5.0-2-amd64 #1 SMP Debian 5.5.17-1 (2020-04-15) x86_64 GNU/Linux
```
# Java Runtime Information
```
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7-Debian-1)
OpenJDK 64-Bit Server VM (build 14.0.1+7-Debian-1, mixed mode, sharing)
```
A DESCRIPTION OF THE PROBLEM :
# Request for Enhancement
This request may be considered as related to
Provide a way to implement a file-based cookie store, i.e. a way to serialize and deserialize the instances of the `java.net.HttpCookie` class.
The `java.net.HttpCookie` class is proposed to be updated, because of the current design:
1. The `java.net.CookieStore` interface uses (depends on) the `java.net.HttpCookie` class.
2. The `java.net.HttpCookie` class is `final`.
# Rationale
The file-based cookie store represents a quite commonly used use case.
Currently, there is no straightforward (simple and easy) way to implement such a store, because there is no way to serialize and deserialize the instances of the `java.net.HttpCookie` class.
# Observations on current `java.net.HttpCookie` class
Please, consider the below observations on the **current** design and implementation of the `java.net.HttpCookie` class.
## 1. The class is not serializable
At least, the class does not implement the `java.io.Serializable` interface.
## 2. The class does not provide an external string representation
This is to serialize and deserialize without losing the information.
Counterexample. Using the methods, `toString()` and `parse(java.lang.String)`, causes the information loss.
## 3. The class completely hides the data as its state
Currently, there is no way to «deconstruct» and «construct» an instance of the class again using the cookie-related data.
For example, the `getCreationTime()` method is package-private and there is no constructor that accepts the creation time value.
Best regards,
XX.
- duplicates
-
JDK-8048203 java.net.HttpCookies cannot be written to a file
-
- Closed
-
- relates to
-
JDK-8048203 java.net.HttpCookies cannot be written to a file
-
- Closed
-