Skip to content

Commit 6c1b613

Browse files
committed
Get rid of exception in the AbstractContextBasedITextEvent#setMetaInfo
DEVSIX-5887
1 parent 7309ce8 commit 6c1b613

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

commons/src/main/java/com/itextpdf/commons/actions/AbstractContextBasedITextEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ public Class<?> getClassFromContext() {
5858
*
5959
* @param metaInfo meta info
6060
*
61-
* @throws IllegalStateException if the current event already has not null meta info associated with it
61+
* @return true if meta info has been set, false otherwise
6262
*/
63-
public void setMetaInfo(IMetaInfo metaInfo) throws IllegalStateException {
63+
public boolean setMetaInfo(IMetaInfo metaInfo) {
6464
if (this.metaInfo != null) {
65-
throw new IllegalStateException(CommonsExceptionMessageConstant.META_INFO_SHOULDNT_BE_NULL);
65+
return false;
6666
}
6767
this.metaInfo = metaInfo;
68+
return true;
6869
}
6970

7071
/**

commons/src/main/java/com/itextpdf/commons/exceptions/CommonsExceptionMessageConstant.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public final class CommonsExceptionMessageConstant {
3939
public static final String INVALID_USAGE_CONFIGURATION_FORBIDDEN = "Invalid usage of placeholder \"{0}\": any "
4040
+ "configuration is forbidden";
4141
public static final String INVALID_USAGE_FORMAT_REQUIRED = "Invalid usage of placeholder \"{0}\": format is required";
42-
public static final String META_INFO_SHOULDNT_BE_NULL = "Meta info shouldn't be null";
4342
public static final String NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT = "No events were registered for the document!";
4443
public static final String PATTERN_CONTAINS_OPEN_QUOTATION = "Pattern contains open quotation!";
4544
public static final String PATTERN_CONTAINS_UNEXPECTED_CHARACTER = "Pattern contains unexpected character {0}";

commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedITextEventTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public void resetMetaInfoForbiddenTest() {
5656

5757
Assert.assertSame(metaInfoBefore, e.getMetaInfo());
5858

59-
Exception exception = Assert.assertThrows(IllegalStateException.class, () -> e.setMetaInfo(metaInfoAfter));
60-
Assert.assertEquals(CommonsExceptionMessageConstant.META_INFO_SHOULDNT_BE_NULL, exception.getMessage());
59+
Assert.assertFalse(e.setMetaInfo(metaInfoAfter));
6160
}
6261

6362
private static class BasicAbstractContextBasedITextEvent extends AbstractContextBasedITextEvent {

0 commit comments

Comments
 (0)