You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/11/21 11:42:27 UTC
svn commit: r1544097 - in
/subversion/trunk/subversion/bindings/javahl/native:
jniwrapper/jni_io_stream.cpp org_apache_subversion_javahl_util_PropLib.cpp
Author: brane
Date: Thu Nov 21 10:42:26 2013
New Revision: 1544097
URL: http://svn.apache.org/r1544097
Log:
[in subversion/bindings/javahl]
* native/jniwrapper/jni_io_stream.cpp
(InputStream::get_global_stream, InputStream::get_stream,
OutputStream::get_global_stream, OutputStream::get_stream):
Return a NULL stream if the wrapped object is null.
* native/org_apache_subversion_javahl_util_PropLib.cpp
(Java_org_apache_subversion_javahl_util_PropLib_checkNodeProp):
Reimplement in the new style, incidentally fixing a bug where
we did not properly NUL-terminat the propery value string that
was converted from the Java byte array.
Modified:
subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_PropLib.cpp
Modified: subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp?rev=1544097&r1=1544096&r2=1544097&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_io_stream.cpp Thu Nov 21 10:42:26 2013
@@ -172,6 +172,9 @@ svn_stream_t*
InputStream::get_global_stream(Env env, jobject jstream,
const SVN::Pool& pool)
{
+ if (!jstream)
+ return NULL;
+
const bool has_mark = InputStream(env, jstream).mark_supported();
std::auto_ptr<GlobalObject> baton(new GlobalObject(env, jstream));
@@ -194,6 +197,9 @@ InputStream::get_global_stream(Env env,
svn_stream_t* InputStream::get_stream(const SVN::Pool& pool)
{
+ if (!m_jthis)
+ return NULL;
+
const bool has_mark = mark_supported();
svn_stream_t* const stream = svn_stream_create(this, pool.getPool());
@@ -217,6 +223,9 @@ svn_stream_t*
OutputStream::get_global_stream(Env env, jobject jstream,
const SVN::Pool& pool)
{
+ if (!jstream)
+ return NULL;
+
std::auto_ptr<GlobalObject> baton(new GlobalObject(env, jstream));
svn_stream_t* const stream = svn_stream_create(baton.get(), pool.getPool());
@@ -231,6 +240,9 @@ OutputStream::get_global_stream(Env env,
svn_stream_t* OutputStream::get_stream(const SVN::Pool& pool)
{
+ if (!m_jthis)
+ return NULL;
+
svn_stream_t* const stream = svn_stream_create(this, pool.getPool());
svn_stream_set_write(stream, stream_write);
svn_stream_set_close(stream, stream_close_output);
Modified: subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_PropLib.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_PropLib.cpp?rev=1544097&r1=1544096&r2=1544097&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_PropLib.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_PropLib.cpp Thu Nov 21 10:42:26 2013
@@ -29,13 +29,15 @@
#include "../include/org_apache_subversion_javahl_util_PropLib.h"
-#include "JNIStackElement.h"
-#include "JNIStringHolder.h"
-#include "JNIByteArray.h"
-#include "JNIUtil.h"
-#include "InputStream.h"
+#include "jniwrapper/jni_stack.hpp"
+#include "jniwrapper/jni_array.hpp"
+#include "jniwrapper/jni_list.hpp"
+#include "jniwrapper/jni_string.hpp"
+#include "jniwrapper/jni_io_stream.hpp"
+#include "ExternalItem.hpp"
+#include "SubversionException.hpp"
+
#include "EnumMapper.h"
-#include "Path.h"
#include "Pool.h"
#include "svn_props.h"
@@ -82,74 +84,7 @@ private:
const char* m_mime_type;
svn_stream_t* m_contents;
};
-} // anonymous namespace
-
-
-JNIEXPORT jbyteArray JNICALL
-Java_org_apache_subversion_javahl_util_PropLib_checkNodeProp(
- JNIEnv* env, jobject jthis,
- jstring jname, jbyteArray jvalue, jstring jpath, jobject jkind,
- jstring jmime_type, jobject jfile_contents,
- jboolean jskip_some_checks)
-{
- JNIEntry(PropLib, checkLocalProp);
-
- JNIStringHolder name(jname);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- JNIByteArray value(jvalue);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- JNIStringHolder path(jpath);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- svn_node_kind_t kind = EnumMapper::toNodeKind(jkind);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- JNIStringHolder mime_type(jmime_type);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- InputStream contents(jfile_contents);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- // Using a "global" request pool since we don't keep a context with
- // its own pool around for these functions.
- SVN::Pool pool;
-
- PropGetter getter(mime_type.c_str(),
- (jfile_contents ? contents.getStream(pool) : NULL));
-
- svn_string_t propval;
- propval.data = reinterpret_cast<const char*>(value.getBytes());
- propval.len = value.getLength();
-
- const svn_string_t* canonval;
- SVN_JNI_ERR(svn_wc_canonicalize_svn_prop(
- &canonval, name.c_str(), &propval, path.c_str(),
- kind, svn_boolean_t(jskip_some_checks),
- PropGetter::callback, &getter,
- pool.getPool()),
- NULL);
-
- return JNIUtil::makeJByteArray(canonval->data, int(canonval->len));
-}
-
-
-#include "jniwrapper/jni_stack.hpp"
-#include "jniwrapper/jni_array.hpp"
-#include "jniwrapper/jni_list.hpp"
-#include "jniwrapper/jni_string.hpp"
-#include "ExternalItem.hpp"
-#include "SubversionException.hpp"
-
-namespace {
struct FormatRevision
{
explicit FormatRevision(const svn_opt_revision_t* const& revarg,
@@ -278,6 +213,52 @@ private:
} // anoymous namespace
+JNIEXPORT jbyteArray JNICALL
+Java_org_apache_subversion_javahl_util_PropLib_checkNodeProp(
+ JNIEnv* jenv, jobject jthis,
+ jstring jname, jbyteArray jvalue, jstring jpath, jobject jkind,
+ jstring jmime_type, jobject jfile_contents,
+ jboolean jskip_some_checks)
+{
+ SVN_JAVAHL_JNI_TRY(PropLib, checkLocalProp)
+ {
+ const Java::Env env(jenv);
+
+ const svn_node_kind_t kind = EnumMapper::toNodeKind(jkind);
+ if (env.ExceptionCheck())
+ throw Java::SignalExceptionThrown();
+
+ const Java::String name_str(env, jname);
+ const Java::ByteArray value(env, jvalue);
+ const Java::String path_str(env, jpath);
+ const Java::String mime_type_str(env, jmime_type);
+ Java::InputStream file_contents(env, jfile_contents);
+
+ // Using a "global" request pool since we don't keep a context
+ // with its own pool around for these functions.
+ SVN::Pool pool;
+
+ const Java::String::Contents name(name_str);
+ const Java::String::Contents path(path_str);
+ const Java::String::Contents mime_type(mime_type_str);
+ PropGetter getter(mime_type.c_str(), file_contents.get_stream(pool));
+
+ const svn_string_t* canonval;
+ SVN_JAVAHL_CHECK(env,
+ svn_wc_canonicalize_svn_prop(
+ &canonval, name.c_str(),
+ Java::ByteArray::Contents(value).get_string(pool),
+ path.c_str(), kind,
+ svn_boolean_t(jskip_some_checks),
+ PropGetter::callback, &getter,
+ pool.getPool()));
+ return Java::ByteArray(env, canonval->data, jint(canonval->len)).get();
+ }
+ SVN_JAVAHL_JNI_CATCH;
+ return NULL;
+}
+
+
JNIEXPORT jobject JNICALL
Java_org_apache_subversion_javahl_util_PropLib_parseExternals(
JNIEnv* jenv, jobject jthis,