Return-Path: X-Original-To: apmail-stratos-dev-archive@minotaur.apache.org Delivered-To: apmail-stratos-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA6DB10A3F for ; Thu, 9 Jan 2014 09:46:19 +0000 (UTC) Received: (qmail 76529 invoked by uid 500); 9 Jan 2014 09:46:07 -0000 Delivered-To: apmail-stratos-dev-archive@stratos.apache.org Received: (qmail 76479 invoked by uid 500); 9 Jan 2014 09:46:05 -0000 Mailing-List: contact dev-help@stratos.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stratos.incubator.apache.org Delivered-To: mailing list dev@stratos.incubator.apache.org Received: (qmail 76454 invoked by uid 99); 9 Jan 2014 09:46:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jan 2014 09:46:01 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of pradeepfn@gmail.com designates 209.85.212.50 as permitted sender) Received: from [209.85.212.50] (HELO mail-vb0-f50.google.com) (209.85.212.50) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jan 2014 09:45:58 +0000 Received: by mail-vb0-f50.google.com with SMTP id w18so2028137vbj.37 for ; Thu, 09 Jan 2014 01:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Zt7TpDGzkmtknhrsXzAcFxHu4fQL6lhBn92zKuScENE=; b=00KUMi8k6LUb0PB6ydlxL8CJ4n1mIS2TyPQGT+qruOPICMQC+M0haTh96dRAWzUbGE vRwL9iR/M/71s8aouqkw7Wq0RvYFlsxAT93qylK3gSY5iogRAIwJbp3MGkPActGAcuiw 0hVbBcTVmCjhBDe46D6rYishIO3J2Ih3E9saXFeTBJKYdj3PZ4T4Xh4yqTZqzeR0uCrH btZ9h6axDSQILD0TscY1k1wqqqQzzaWPQXf5kmCbr6bBj5yIFWnzlXuCES5/IYi0Ke7q Yf7LadvyssuqvwQ5kAof+jIUsBK/xTjn3NcbBJvoc9GJGN5Ksr0i7IkkGg+vvnoUC2UM ncLw== X-Received: by 10.53.7.193 with SMTP id de1mr5502vdd.91.1389260737230; Thu, 09 Jan 2014 01:45:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.58.65.37 with HTTP; Thu, 9 Jan 2014 01:45:17 -0800 (PST) In-Reply-To: References: From: Pradeep Fernando Date: Thu, 9 Jan 2014 15:15:17 +0530 Message-ID: Subject: Re: Exceptions are thrown in Cartridge agent thread To: dev Content-Type: multipart/alternative; boundary=001a113603e0be3bf104ef8678ce X-Virus-Checked: Checked by ClamAV on apache.org --001a113603e0be3bf104ef8678ce Content-Type: text/plain; charset=UTF-8 On Thu, Jan 9, 2014 at 3:08 PM, Lahiru Sandaruwan wrote: > > > > On Thu, Jan 9, 2014 at 2:58 PM, Nirmal Fernando wrote: > >> Yes, we should throw exceptions carefully. However, we should analyse >> this particular code segment. >> >> Looking at the code Lahiru sent, I tend to agree with the original >> author. Cause, I don't think without the presence of those properties >> Cartridge Agent could survive. >> > > yeah. that is the point to consider... > > I think the first two are mandatory, > Then fail gracefully after logging the exception scenario. We don't have to proceed further. third we can proceed without having. > > > wdyt? >> >> >> On Thu, Jan 9, 2014 at 2:47 PM, Pradeep Fernando wrote: >> >>> The original author has opted for Runtime exceptions. >>> >>> - It is somewhat controversial to use runtime exceptions in your code. >>> - if you really mean it, we should not log it IMO. >>> - Those get handled by the JVM at the end of the day. (like nullpointers) >>> >>> I think we should use checked exceptions here.. >>> >>> >>> On Thu, Jan 9, 2014 at 2:21 PM, Lahiru Sandaruwan wrote: >>> >>>> Hi, >>>> >>>> $subject. I think the correct way is to log without throwing... >>>> >>>> >>>> >>>> String jndiPropertiesDir = >>>> System.getProperty(CartridgeAgentConstants.JNDI_PROPERTIES_DIR); >>>> if(StringUtils.isBlank(jndiPropertiesDir)) { >>>> throw new RuntimeException(String.format("System property >>>> not found: %s", CartridgeAgentConstants.JNDI_PROPERTIES_DIR)); >>>> } >>>> >>>> String payloadPath = >>>> System.getProperty(CartridgeAgentConstants.PARAM_FILE_PATH); >>>> if(StringUtils.isBlank(payloadPath)) { >>>> throw new RuntimeException(String.format("System property >>>> not found: %s", CartridgeAgentConstants.PARAM_FILE_PATH)); >>>> } >>>> >>>> String extensionsDir = >>>> System.getProperty(CartridgeAgentConstants.EXTENSIONS_DIR); >>>> if(StringUtils.isBlank(extensionsDir)) { >>>> throw new RuntimeException(String.format("System property >>>> not found: %s", CartridgeAgentConstants.EXTENSIONS_DIR)); >>>> } >>>> >>>> Thanks. >>>> -- >>>> -- >>>> Lahiru Sandaruwan >>>> Software Engineer, >>>> Platform Technologies, >>>> WSO2 Inc., http://wso2.com >>>> lean.enterprise.middleware >>>> >>>> email: lahirus@wso2.com cell: (+94) 773 325 954 >>>> blog: http://lahiruwrites.blogspot.com/ >>>> twitter: http://twitter.com/lahirus >>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146 >>>> >>>> >>> >>> >>> -- >>> Pradeep Fernando. >>> http://pradeepfernando.blogspot.com/ >>> >> >> >> >> -- >> Best Regards, >> Nirmal >> >> Nirmal Fernando. >> PPMC Member & Committer of Apache Stratos, >> Senior Software Engineer, WSO2 Inc. >> >> Blog: http://nirmalfdo.blogspot.com/ >> > > > > -- > -- > Lahiru Sandaruwan > Software Engineer, > Platform Technologies, > WSO2 Inc., http://wso2.com > lean.enterprise.middleware > > email: lahirus@wso2.com cell: (+94) 773 325 954 > blog: http://lahiruwrites.blogspot.com/ > twitter: http://twitter.com/lahirus > linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146 > > -- Pradeep Fernando. http://pradeepfernando.blogspot.com/ --001a113603e0be3bf104ef8678ce Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Thu, Jan 9, 2014 at 3:08 PM, Lahiru Sandaruwan <lahirus@wso2.com= > wrote:



On Thu, Jan 9, 201= 4 at 2:58 PM, Nirmal Fernando <nirmal070125@gmail.com> = wrote:
Yes, we should throw exceptions carefully. However, we should analys= e this particular code segment.

Looking at the code Lahiru sent, I tend to agree with the origina= l author. Cause, I don't think without the presence of those properties= Cartridge Agent could survive.

yeah. that is the point to consider...

= I think the first two are mandatory,
Then fail gracefully after logging the exception scenario. We don't = have to proceed further.

third we can proceed witho= ut having.


wdyt?


On Thu, Jan 9, 2014 at 2:47 PM, Pradeep Fernando <prad= eepfn@gmail.com> wrote:
The original author has opt= ed for Runtime exceptions.

- It is somewhat controversia= l to use runtime exceptions in your code.
- if you really mean it, we should not log it IMO.
- Those get handled by the JVM at the end of the day. (like nullpointe= rs)

I think we should use checked exceptions here.= .


On Thu, Jan 9, 2014 at 2:21 PM, Lahiru Sandaruwan <lahirus@wso2.com>= wrote:
Hi,

$subject. I think the correct way i= s to log without throwing...


<= br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 String jndiPropertiesDir =3D Syst= em.getProperty(CartridgeAgentConstants.JNDI_PROPERTIES_DIR);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(StringUtils.isBlank(jndiPropertiesDir))= {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 throw new RuntimeExc= eption(String.format("System property not found: %s", CartridgeAg= entConstants.JNDI_PROPERTIES_DIR));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0= =C2=A0 String payloadPath =3D System.getProperty(CartridgeAgentConstants.P= ARAM_FILE_PATH);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(StringUtils.isBla= nk(payloadPath)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 thro= w new RuntimeException(String.format("System property not found: %s&qu= ot;, CartridgeAgentConstants.PARAM_FILE_PATH));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 = =C2=A0 =C2=A0 String extensionsDir =3D System.getProperty(CartridgeAgentCon= stants.EXTENSIONS_DIR);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(StringUtil= s.isBlank(extensionsDir)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 throw new RuntimeException(String.format("System property not f= ound: %s", CartridgeAgentConstants.EXTENSIONS_DIR));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }




<= font color=3D"#888888">--
Pradeep Fernando.
http://pradeepfernando.blogspot.= com/



--
Best Regards,
Nirmal

Nirmal = Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.




--
Pradeep Fern= ando.
http://pradeepfer= nando.blogspot.com/
--001a113603e0be3bf104ef8678ce--