[ 
https://issues.apache.org/jira/browse/CAMEL-12343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16394895#comment-16394895
 ] 

ASF GitHub Bot commented on CAMEL-12343:
----------------------------------------

davsclaus closed pull request #2252: CAMEL-12343 : refer to new constructor 
with defaultCamelContext for deprecated constructor
URL: https://github.com/apache/camel/pull/2252
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
 
b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
index 71c6d6b43ee..b5884b42290 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
@@ -18,6 +18,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultMessage;
 
 /**
@@ -31,6 +32,7 @@
      */
     @Deprecated
     public GenericFileMessage() {
+        this(new DefaultCamelContext());
     }
 
     public GenericFileMessage(CamelContext camelContext) {
@@ -42,7 +44,7 @@ public GenericFileMessage(CamelContext camelContext) {
      */
     @Deprecated
     public GenericFileMessage(GenericFile<T> file) {
-        this.file = file;
+        this(new DefaultCamelContext(), file);
     }
 
     public GenericFileMessage(CamelContext camelContext, GenericFile<T> file) {
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
index e226de0ecf8..30ad2ec43f1 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
@@ -54,6 +54,7 @@
      */
     @Deprecated
     public DefaultMessage() {
+        this(new DefaultCamelContext());
     }
 
     public DefaultMessage(CamelContext camelContext) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Using DefautMessage() and GenericFileMessage() without CamelContext throw 
> Exception
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-12343
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12343
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.20.0, 2.20.1, 2.20.2, 2.21.0
>            Reporter: Farès Hassak
>            Priority: Major
>
> Hello,
> I am using version 2.19.2 and try to migrate to version 2.20.2 (and then to 
> 2.21.0).
> Using DefautMessage() and GenericFileMessage() without CamelContext throw 
> Exception :
> {code:java}
> java.lang.IllegalArgumentException: CamelContext must be specified on: 
> Message[] at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:342)
> {code}
> In version 2.20.0, I see that these constructor was deprecated and new 
> contructors was introduced for this new feature 
> https://issues.apache.org/jira/browse/CAMEL-11149 :
> To remain better backward compatibility, i would suggest to refer the new 
> constructor in deprecated contructor  :
> {code:java}
>  @Deprecated
>     public DefaultMessage() {
>         this(new DefaultCamelContext()); //use new contructor with 
> DefaultCamelContext to avoid exception
>     }
>     public DefaultMessage(CamelContext camelContext) {
>         setCamelContext(camelContext);
>     }
> {code}
> {code:java}
>     @Deprecated
>     public GenericFileMessage() {
>         this(new DefaultCamelContext()); //use new contructor with 
> DefaultCamelContext to avoid exception
>     }
>     public GenericFileMessage(CamelContext camelContext) {
>         super(camelContext);
>     }
>     /**
>      * @deprecated use {@link #GenericFileMessage(CamelContext, GenericFile)}
>      */
>     @Deprecated
>     public GenericFileMessage(GenericFile<T> file) {
>         this(new DefaultCamelContext(), file); //use new contructor with 
> DefaultCamelContext to avoid exception
>     }
>     public GenericFileMessage(CamelContext camelContext, GenericFile<T> file) 
> {
>         super(camelContext);
>         this.file = file;
>     }
> {code}
> Otherwise, the deprecated constructeur must be deleted in order to detect 
> errors at compile time and not at runtime.
> Farès



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to