Skip to content

Commit 45c23af

Browse files
committed
Context.attribute(key) should be marked @nullable on return fix jooby-project#2306
1 parent 6c9d464 commit 45c23af

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

jooby/src/main/java/io/jooby/Context.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public interface Context extends Registry {
8181
*
8282
* @param key Attribute key.
8383
* @param <T> Attribute type.
84-
* @return Attribute value.
84+
* @return Attribute value or <code>null</code>.
8585
*/
86-
@Nonnull <T> T attribute(@Nonnull String key);
86+
@Nullable <T> T attribute(@Nonnull String key);
8787

8888
/**
8989
* Set an application attribute.

jooby/src/main/java/io/jooby/DefaultContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public interface DefaultContext extends Context {
7979
* @param <T> Attribute type.
8080
* @return Attribute value.
8181
*/
82-
@Override @Nonnull default <T> T attribute(@Nonnull String key) {
82+
@Override @Nullable default <T> T attribute(@Nonnull String key) {
8383
T attribute = (T) getAttributes().get(key);
8484
if (attribute == null) {
8585
Map<String, Object> globals = getRouter().getAttributes();

jooby/src/main/java/io/jooby/ForwardingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ForwardingContext(@Nonnull Context context) {
6868
return ctx.getAttributes();
6969
}
7070

71-
@Nonnull @Override public <T> T attribute(@Nonnull String key) {
71+
@Nullable @Override public <T> T attribute(@Nonnull String key) {
7272
return ctx.attribute(key);
7373
}
7474

0 commit comments

Comments
 (0)