Author: mladen.turk(a)jboss.com
Date: 2007-10-12 07:09:32 -0400 (Fri, 12 Oct 2007)
New Revision: 1104
Modified:
trunk/sight/java/org/jboss/sight/Service.java
trunk/sight/native/include/sight_local.h
trunk/sight/native/os/linux/service.c
trunk/sight/native/os/solaris/service.c
trunk/sight/native/os/windows/service.c
trunk/sight/native/share/error.c
Log:
Throw IllegalArgumentException for APR_EINVAL
Modified: trunk/sight/java/org/jboss/sight/Service.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Service.java 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/java/org/jboss/sight/Service.java 2007-10-12 11:09:32 UTC (rev 1104)
@@ -103,7 +103,7 @@
}
protected Service(ServiceControlManager scm, String name)
- throws OutOfMemoryError, OperatingSystemException
+ throws OutOfMemoryError, OperatingSystemException, IllegalArgumentException
{
super(scm.POOL);
int e = open0(this, INSTANCE, scm.INSTANCE,
@@ -117,7 +117,7 @@
protected Service(ServiceControlManager scm, String name,
EnumSet<GenericAccessRights> access)
- throws OutOfMemoryError, OperatingSystemException
+ throws OutOfMemoryError, OperatingSystemException, IllegalArgumentException
{
super(scm.POOL);
int e = open0(this, INSTANCE, scm.INSTANCE,
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/native/include/sight_local.h 2007-10-12 11:09:32 UTC (rev 1104)
@@ -118,6 +118,7 @@
void throwIOException(JNIEnv *, const char *);
void throwMemoryException(JNIEnv *, const char *, int, const char *);
void throwNullPointerException(JNIEnv *, const char *, int, const char *);
+void throwArgumentException(JNIEnv *, const char *, int, const char *);
void throwAprException(JNIEnv *, apr_status_t);
void throwAprExceptionEx(JNIEnv *, const char *, int, apr_status_t);
void throwAprIOException(JNIEnv *, apr_status_t);
Modified: trunk/sight/native/os/linux/service.c
===================================================================
--- trunk/sight/native/os/linux/service.c 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/native/os/linux/service.c 2007-10-12 11:09:32 UTC (rev 1104)
@@ -151,12 +151,18 @@
UNREFERENCED_O;
UNREFERENCED(access);
+ if (!name) {
+ throwArgumentException(_E, THROW_FMARK, NULL);
+ return APR_EINVAL;
+ }
if (!no || !no->pool) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
if (!ns || !ns->native) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
SIGHT_LOCAL_TRY(ns) {
@@ -181,7 +187,7 @@
if (!sight_wmatch(sname, smatch)) {
SET_IFIELD_S(0001, thiz, sname);
SET_IFIELD_S(0004, thiz, sent->d_name);
-
+
/* TODO: Launch script with status param
* to figure out the state.
*/
Modified: trunk/sight/native/os/solaris/service.c
===================================================================
--- trunk/sight/native/os/solaris/service.c 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/native/os/solaris/service.c 2007-10-12 11:09:32 UTC (rev 1104)
@@ -154,12 +154,18 @@
UNREFERENCED_O;
UNREFERENCED(access);
+ if (!name) {
+ throwArgumentException(_E, THROW_FMARK, NULL);
+ return APR_EINVAL;
+ }
if (!no || !no->pool) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
if (!ns || !ns->native) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
@@ -185,7 +191,7 @@
if (!sight_wmatch(sname, smatch)) {
SET_IFIELD_S(0001, thiz, sname);
SET_IFIELD_S(0004, thiz, sent->d_name);
-
+
/* TODO: Launch script with status param
* to figure out the state.
*/
Modified: trunk/sight/native/os/windows/service.c
===================================================================
--- trunk/sight/native/os/windows/service.c 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/native/os/windows/service.c 2007-10-12 11:09:32 UTC (rev 1104)
@@ -165,12 +165,19 @@
SIGHT_ALLOC_CSTRING(name);
BYTE buf[1024];
UNREFERENCED_O;
+
+ if (!name) {
+ throwArgumentException(_E, THROW_FMARK, NULL);
+ return APR_EINVAL;
+ }
if (!no || !no->pool) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
if (!ns || !ns->native) {
SIGHT_FREE_CSTRING(name);
+ throwArgumentException(_E, THROW_FMARK, NULL);
return APR_EINVAL;
}
SIGHT_LOCAL_TRY(ns) {
Modified: trunk/sight/native/share/error.c
===================================================================
--- trunk/sight/native/share/error.c 2007-10-12 09:27:59 UTC (rev 1103)
+++ trunk/sight/native/share/error.c 2007-10-12 11:09:32 UTC (rev 1104)
@@ -115,7 +115,10 @@
if (f != file) {
f++;
}
- sprintf(fmt, "%s (%s)+%d", msg, f, line);
+ if (msg)
+ sprintf(fmt, "%s (%s)+%d", msg, f, line);
+ else
+ sprintf(fmt, "(%s)+%d", msg, f, line);
throwClass(env, clazz, &fmt[0]);
}
else {
@@ -159,6 +162,16 @@
}
/*
+ * Convenience function to help throw an java.lang.IllegalArgumentException.
+ */
+void throwArgumentException(JNIEnv *env, const char *file, int line,
+ const char *msg)
+{
+ throwDebug(env, "java/lang/IllegalArgumentException", file, line, msg);
+}
+
+
+/*
* Convenience function to help throw an java.lang.Exception
* with string representation of APR error code.
*/