Skip to content

Commit e2d5cf3

Browse files
ar3emiText-CI
authored andcommitted
Get rid of exception in the AbstractContextBasedITextEvent#setMetaInfo
DEVSIX-5887 Autoported commit. Original commit hash: [6c1b6135d]
1 parent 946e582 commit e2d5cf3

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

itext.tests/itext.commons.tests/itext/commons/actions/AbstractContextBasedITextEventTest.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
23-
using System;
2423
using iText.Commons.Actions.Contexts;
2524
using iText.Commons.Actions.Data;
2625
using iText.Commons.Ecosystem;
27-
using iText.Commons.Exceptions;
2826
using iText.Test;
2927

3028
namespace iText.Commons.Actions {
@@ -45,10 +43,7 @@ public virtual void ResetMetaInfoForbiddenTest() {
4543
AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent e = new AbstractContextBasedITextEventTest.BasicAbstractContextBasedITextEvent
4644
(CommonsProductData.GetInstance(), metaInfoBefore);
4745
NUnit.Framework.Assert.AreSame(metaInfoBefore, e.GetMetaInfo());
48-
Exception exception = NUnit.Framework.Assert.Catch(typeof(InvalidOperationException), () => e.SetMetaInfo(
49-
metaInfoAfter));
50-
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.META_INFO_SHOULDNT_BE_NULL, exception.Message
51-
);
46+
NUnit.Framework.Assert.IsFalse(e.SetMetaInfo(metaInfoAfter));
5247
}
5348

5449
private class BasicAbstractContextBasedITextEvent : AbstractContextBasedITextEvent {

itext/itext.commons/itext/commons/actions/AbstractContextBasedITextEvent.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ You should have received a copy of the GNU Affero General Public License
2323
using System;
2424
using iText.Commons.Actions.Contexts;
2525
using iText.Commons.Actions.Data;
26-
using iText.Commons.Exceptions;
2726

2827
namespace iText.Commons.Actions {
2928
/// <summary>Represents a context-based event.</summary>
@@ -51,11 +50,13 @@ public virtual Type GetClassFromContext() {
5150

5251
/// <summary>Sets meta info.</summary>
5352
/// <param name="metaInfo">meta info</param>
54-
public virtual void SetMetaInfo(IMetaInfo metaInfo) {
53+
/// <returns>true if meta info has been set, false otherwise</returns>
54+
public virtual bool SetMetaInfo(IMetaInfo metaInfo) {
5555
if (this.metaInfo != null) {
56-
throw new InvalidOperationException(CommonsExceptionMessageConstant.META_INFO_SHOULDNT_BE_NULL);
56+
return false;
5757
}
5858
this.metaInfo = metaInfo;
59+
return true;
5960
}
6061

6162
/// <summary>Obtains stored meta info associated with the event.</summary>

itext/itext.commons/itext/commons/exceptions/CommonsExceptionMessageConstant.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public sealed class CommonsExceptionMessageConstant {
4343

4444
public const String INVALID_USAGE_FORMAT_REQUIRED = "Invalid usage of placeholder \"{0}\": format is required";
4545

46-
public const String META_INFO_SHOULDNT_BE_NULL = "Meta info shouldn't be null";
47-
4846
public const String NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT = "No events were registered for the document!";
4947

5048
public const String PATTERN_CONTAINS_OPEN_QUOTATION = "Pattern contains open quotation!";

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7309ce8ca4c7782f482d4c4cf2b68a82fc305745
1+
6c1b6135d55c607dd1098c733cc1a3b300d5cc96

0 commit comments

Comments
 (0)