From 8bd1fd3715c3693e4445f40360d41125ea8a4431 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 4 Jul 2012 23:32:49 +0200 Subject: [PATCH] moved getInputStream() not-null requirement to InputStreamSource itself; removed misleading "throws IllegalStateException" declaration Issue: SPR-9561 --- .../java/org/springframework/core/io/AbstractResource.java | 2 +- .../java/org/springframework/core/io/InputStreamSource.java | 3 ++- .../src/main/java/org/springframework/core/io/Resource.java | 5 ----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java index 20b44df103..3933128d64 100644 --- a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java @@ -173,7 +173,7 @@ public abstract class AbstractResource implements Resource { * This implementation always returns null, * assuming that this resource type does not have a filename. */ - public String getFilename() throws IllegalStateException { + public String getFilename() { return null; } diff --git a/spring-core/src/main/java/org/springframework/core/io/InputStreamSource.java b/spring-core/src/main/java/org/springframework/core/io/InputStreamSource.java index 33bac47915..7e1f58a0c7 100644 --- a/spring-core/src/main/java/org/springframework/core/io/InputStreamSource.java +++ b/spring-core/src/main/java/org/springframework/core/io/InputStreamSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public interface InputStreamSource { * as JavaMail, which needs to be able to read the stream multiple times when * creating mail attachments. For such a use case, it is required * that each getInputStream() call returns a fresh stream. + * @return the input stream for the underlying resource (must not be {@code null}) * @throws IOException if the stream could not be opened * @see org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource) */ diff --git a/spring-core/src/main/java/org/springframework/core/io/Resource.java b/spring-core/src/main/java/org/springframework/core/io/Resource.java index 0d088b9202..b242ffc2c4 100644 --- a/spring-core/src/main/java/org/springframework/core/io/Resource.java +++ b/spring-core/src/main/java/org/springframework/core/io/Resource.java @@ -133,9 +133,4 @@ public interface Resource extends InputStreamSource { */ String getDescription(); - /** - * {@inheritDoc} - * @return the input stream for the underlying resource (must not be {@code null}). - */ - public InputStream getInputStream() throws IOException; }